I'm tuning my query for mysql. the schema has index of user_id (following..) but the index is not used. why?
Env: MySQL4.0.27,MyISAM
SQL is the following :
SELECT type,SUM(value_a) A, SUM(value_b) B, SUM(value_c) C
FROM big_record_table
WHERE user_id='<user_id>'
GROUP BY type
Explain:
|table |type |possible_keys |key |key_len |ref |rows |Extra|
|big_record_table| ALL| user_id_key|||| 1059756 |Using where; Using temporary; Using filesort|
could you describe detail?
scheme is following:
CREATE TABLE `big_record_table` (
`user_id` int(11) NOT NULL default '0',
`type` enum('type_a','type_b','type_c') NOT NULL default 'type_a',
`value_a` bigint(20) NOT NULL default '0',
`value_b` bigint(20) default NULL,
`value_c` bigint(20) NOT NULL default '0',
KEY `user_id_key` (`user_id`)
) TYPE=MyISAM