Here's the SHOW CREATE TABLE for my 'classifieds_img':
CREATE TABLE `classifieds_img` (
`id` varchar(15) NOT NULL,
`sorter` int(1) NOT NULL DEFAULT '0',
`image` varchar(20) NOT NULL,
PRIMARY KEY (`id`,`sorter`),
UNIQUE KEY `Unique` (`id`,`image`),
KEY `sorter` (`sorter`,`image`),
KEY `ID` (`id`),
KEY `View` (`id`,`sorter`,`image`),
KEY `image` (`image`),
KEY `sorter_2` (`sorter`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
All of those indices were ones created for the testing here. There are minor differences (I'm using `id` varchar(15), where you're using smallint(5), and you have `image` first where I have it last), but essentially the same.
And the SHOW CREATE TABLE for my 'classifieds':
CREATE TABLE `classifieds` (
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL DEFAULT '',
`category` varchar(50) NOT NULL,
`subcat` varchar(50) DEFAULT NULL,
`contact` varchar(50) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`tele` varchar(50) DEFAULT NULL,
`vehicle_type` varchar(30) DEFAULT NULL,
`seller_type` varchar(20) DEFAULT NULL,
`make` varchar(100) DEFAULT NULL,
`model` varchar(100) DEFAULT NULL,
`year` varchar(4) DEFAULT NULL,
`mileage` varchar(10) DEFAULT NULL,
`price` varchar(30) DEFAULT NULL,
`postdate` varchar(14) NOT NULL,
`expiration` varchar(14) NOT NULL DEFAULT '0',
`title` varchar(50) DEFAULT NULL,
`description` text NOT NULL,
`status` varchar(10) NOT NULL,
`startdate` varchar(14) DEFAULT NULL
PRIMARY KEY (`id`),
KEY `username` (`username`,`status`),
KEY `category` (`category`,`subcat`,`expiration`),
KEY `list` (`category`,`subcat`)
) ENGINE=MyISAM AUTO_INCREMENT=609840 DEFAULT CHARSET=latin1
For testing, I removed classifieds_which completely from the query, and it's still just as slow so I didn't bother showing that one.
There are currently 41,669 rows in 'classifieds', and 25,682 rows in 'classifieds_img' (where all but 5 of them have sorter = 0; I haven't implemented the ability to upload multiple pictures yet, so all ads with an image will just have 1).
Running the query from Putty still took 0.57s, so I don't think that PMA is the problem. If it's running fast for you, then can it be something to do with the column types that I'm using??