Using MySQL version 5.5.28,
I have a table defined as such:
CREATE TABLE IF NOT EXISTS `groups` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(80) NOT NULL,
`desc` text NOT NULL,
`permissions` varchar(80) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
As you can see, it's pretty simple. I have a primary key on the id field. Now, I query against it using something like this:
SELECT permissions FROM groups WHERE id IN ('9', '8', '6','14','11','7','5');
Unfortunately it refuses to use the key, and it shows up in my slow query log.
Performing EXPLAIN on it provides:
mysql> EXPLAIN SELECT permissions FROM groups WHERE id IN ('9', '8', '6','14','11','7','5');
+----+-------------+--------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | groups | ALL | PRIMARY | NULL | NULL | NULL | 16 | Using where |
+----+-------------+--------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)
It only has less than 20 rows in the entire table, so I get why it wouldn't likely use the index. But, why would this be a "slow query" for MySQL?