I have a very simple query which really needs to be as fast as possible…
The query is:
select users.userid, users.firstname, users.lastname
from users_table users
where userid IN(1,4,6)
userid set as the primary key…
EXPLAIN returns the following:
id |select_type|table|type |possible_keys|key |key_len|ref |rows|Extra
1 |SIMPLE |users|range|PRIMARY |PRIMARY|4 |NULL|3 |Using where
Now, I was under the impression that ‘Using where’ is a bad thing?
Can anybody explain why I might be seeing this?
In your query, the where is the only thing it can use. It looks like it’s using a primary key due to the
INclause being direct comparison to an indexed field (in this case your pk) so it don’t get much better than this! Actually, it’s impossible to get better than this…