Strange use of the index in Mysql

Posted by user309067 on Stack Overflow See other posts from Stack Overflow or by user309067
Published on 2010-04-05T07:33:38Z Indexed on 2010/04/05 7:43 UTC
Read the original article Hit count: 220

Filed under:
|
|
|

explain SELECT feed_objects.* FROM feed_objects WHERE (feed_objects.feed_id IN (165,160,159,158,157,153,152,151,150,149,148,147,129,128,127,126,125,124,122,121,120,119,118,117,116,115,114,113,111,110)) ;

+----+-------------+--------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table        | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+----+-------------+--------------+------+---------------+------+---------+------+------+-------------+
|  1 | SIMPLE      | feed_objects | ALL  | by_feed_id    | NULL | NULL    | NULL |  188 | Using where |
+----+-------------+--------------+------+---------------+------+---------+------+------+-------------+

Not used index 'by_feed_id'

But when I point less than the values in the "WHERE" - everything is working right

explain SELECT feed_objects.* FROM feed_objects WHERE (feed_objects.feed_id IN (165,160,159,158,157,153,152,151,150,149,148,147,129,128,127,125,124)) ;

+----+-------------+--------------+-------+---------------+------------+---------+------+------+-------------+
| id | select_type | table        | type  | possible_keys | key        | key_len | ref  | rows | Extra       |
+----+-------------+--------------+-------+---------------+------------+---------+------+------+-------------+
|  1 | SIMPLE      | feed_objects | range | by_feed_id    | by_feed_id | 9       | NULL |   18 | Using where |
+----+-------------+--------------+-------+---------------+------------+---------+------+------+-------------+

Used index 'by_feed_id'

What is the problem?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql