I have a table (users) with columns like
id INT AUTOINVREMENT PRIMARY
uid INT index
email CHAR(128) UNIQUE
activated TINYINT
And I will need to query this table as follows:
SELECT * FROM users WHERE uid = ? AND activated = 1
My questions are that since the “uid” column has an index in order to get the best performance for the above query, do I also need to set another index in the “activated” column? This table (will be large) will have great access to the "INSERT", "UPDATE", and also "SELECT" statements.
As I learned from other sources, the indexes are opposite the INSERT and UPDATE statements, so if the index in the uid column is enough for the index above, I won’t need to set another index for the activated one for “insert and update performance”.
source
share