开发者

Why is this query not using indexing? [duplicate]

开发者 https://www.devze.com 2023-03-20 13:04 出处:网络
This question already has answers here: MySQL not using indexes with WHERE IN clause? (5 answers) Closed 8 years ago.
This question already has answers here: MySQL not using indexes with WHERE IN clause? (5 answers) Closed 8 years ago.
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_versi开发者_运维技巧ons', '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 ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消