I have a simple mysql query, but when I have a lot of records (currently 103,0000), the performance is very slow and it says it uses filesort, im not sure why that is why it is slow. Anyone have suggestions for speeding it up? or stop it with filesort?
MYSQL query:
SELECT adverts .* FROM adverts WHERE ( price >='0' ) AND ( adverts.status = 1 ) AND ( adverts.approved = 1 ) ORDER BY date_updated DESC LIMIT 19990 , 10
Explanation Results:
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE adverts range price price 4 NULL 103854 Using where; Using filesort
Here is a table of declarations and indexes:
CREATE TABLE `adverts` ( `advert_id` int(10) NOT NULL AUTO_INCREMENT, `user_id` int(10) NOT NULL, `type_id` tinyint(1) NOT NULL, `breed_id` int(10) NOT NULL, `advert_type` tinyint(1) NOT NULL, `headline` varchar(50) NOT NULL, `description` text NOT NULL, `price` int(4) NOT NULL, `postcode` varchar(7) NOT NULL, `town` varchar(60) NOT NULL, `county` varchar(60) NOT NULL, `latitude` float NOT NULL, `longitude` float NOT NULL, `telephone1` varchar(15) NOT NULL, `telephone2` varchar(15) NOT NULL, `email` varchar(80) NOT NULL, `status` tinyint(1) NOT NULL DEFAULT '0', `approved` tinyint(1) NOT NULL DEFAULT '0', `date_created` datetime NOT NULL, `date_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `expiry_date` datetime NOT NULL, PRIMARY KEY (`advert_id`), KEY `price` (`price`), KEY `user` (`user_id`), KEY `type_breed` (`type_id`,`breed_id`), KEY `headline_keywords` (`headline`), KEY `date_updated` (`date_updated`), KEY `type_status_approved` (`advert_type`,`status`,`approved`) ) ENGINE=MyISAM AUTO_INCREMENT=103878 DEFAULT CHARSET=utf8