Hi,
I am using a Mysql table products which has a foreign key category_id on the categories table
the foreign key constraint is defined (Innodb engine).
I noticed that when I run EXPLAIN SELECT * from products where category_id=1;
it uses the foreign key, so I see type=Range and Key: my_foreign_key
But when I run EXPLAIN SELECT * from products where category_id IN (1,10);
it uses a full table scan: type=ALL, Key:NULL!!!
Ironically, when I do EXPLAIN SELECT * from products where category_id IN (1,2); It uses type-range and Key: My_foreign_key!
So I guess there is a problem when the category_id uses values that are not contiguous.
Any ideas why?
Thanks