I have a very simple table with two columns, but has 4.5M rows.
CREATE TABLE `content_link` (
`category_id` mediumint(8) unsigned NOT NULL,
`content_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`content_id`,`category_id`),
KEY `content_id` (`content_id`,`category_id`)
) ENGINE=MyISAM;
When I run a simple query like:
SELECT
*
FROM
content_link
WHERE
category_id = '11';
mysql spikes the CPU and takes 2-5 seconds before returning about 10 rows. The data is spread very evenly across the table and I'm accessing indexed fields (I've also analyzed/optimized the table and I never change the content of the table), so what reason is there for the query to take so long?
Edit: It seems navicat was lying to me and my primary key was not actually keyed in the right order as it was displaying the table to me.