mysql optimization / how to use index tip...?
if this is my USERS table
user_id
user_fname
user_lname
user_email
user_pass
user_verified
user_city
user_joined
us开发者_运维问答er_lastlogin
user_about
i set user_id as PRIMARY (is an auto incremental value)
thaen, should i set user_email as INDEX? other suggestion?
You should add indexes to columns that are often used in query conditions, ordering, joining. There is no point in adding an index to a column that doesn't play any role in the query.
If you have thoughts about optimizing a query, at first, you should check it out in EXPLAIN query to see how complex the query is.
You should use indexes when your table is searched more frequently than it gets updated. If your table is searched using user_email
very often, then you may use indexes on that column.
Remember, if user_email
field gets updated more often than being used in a search condition, then it will ultimately lead to a performance overhead.
Go here for further insight.
精彩评论