0
EXPLAIN SELECT `test_versions`.* FROM `test_versions` WHERE (`test_versions`.test_id IN (363,534,271,274,365,390,404,405,406,407,409,182,201,1386,1387,1388,1389,1390,1307,1308,1309,1310,1311,424,423,393,361,357,355,353,352,351,350,347,209,339,340,345,223,305,66,307,303,221,227,228,229,230,231,210,214,215,217,218,219,234,235,236,237,238,239,232,233,212,100,59)) 


Id   select_type  table            type   possible_keys                  key   key_len  ref    row   Extra 
'1', 'SIMPLE',    'test_versions', 'ALL', 'fk_test_versions_on_test_id', NULL, NULL,    NULL, '76', 'Using where; Using filesort'

It's not using indexing which is already specified. I don't want to pass USE INDEX explicitly. What's the problem with this query ?

Dylan Markow
  • 123,080
  • 26
  • 284
  • 201
krunal shah
  • 16,089
  • 25
  • 97
  • 143
  • 3
    Very related: http://stackoverflow.com/questions/586381/mysql-not-using-indexes-with-where-in-clause – Mat Jul 14 '11 at 14:29

1 Answers1

0

Use joins when you want a join (which under the hood can use indexes) but do not need to modify any of the objects and use includes when you want eager loading but will need to modify some of the objects.

yfeldblum
  • 65,165
  • 12
  • 129
  • 169