SELECT * FROM ( SELECT a.title, a.askprice, a.picture, a.description, a.userid, a.id FROM mm_ads AS a WHERE a.category = 227 AND a.status = 1 ORDER BY id DESC LIMIT 300 ) t LIMIT 40,20
If the goal is to speed up the query, you can create a composite index:
ALTER TABLE `mm_ads` ADD INDEX `mm_ads_index` (`category` ASC, `status` ASC, `id` DESC);
source share