Reputation: 6276
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?
Upvotes: 2
Views: 1181
Reputation: 41428
In your query, the where is the only thing it can use. It looks like it's using a primary key due to the IN
clause 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...
Upvotes: 2
Reputation: 33678
It's ok to have "Using where" in MySQL because of this issue. Check the key
column to see if the key is actually used.
Upvotes: 2