The table contains 4 columns: id (autoincrement), userid (unique, like ssn), status (TINYINT(1), 0 or 1 values, not NULL), user_info (varchar(1000)).
Should I put index on userid column to increase performance, if:
30% of requests is
"SELECT user_info from Table1 WHERE userid='1234567'";
40% of requests is:
"SELECT user_info from Table1 WHERE userid='1234567' AND status=0";
20% of requests is:
"SELECT user_info from Table1 WHERE userid='1234567' AND status=1";
Or, there is a better way to increase the performance (I should think about indexing of status column somehow)?
Should I change something if instead of (30%,40%,20%) it will actually become (9%,90%,1%), i.e. most requests are for status=0?
Thank you.
An index on
statusis very unlikely to increase the SELECT performance as the column content is not diverse enough. An index onuseridis very likely to increase performance a lot as the column content is very diverse.When you’ve defined the
useridcolumn asuniquethe automatically created unique index should already be used in your queries. So there’s no need to define an additional index.