select advert_id from acr_cache where category_id = ? and region_id = ? order by category_id, region_id, XXX limit 20;
don't forget to mention all the index columns in the order by, or the planner won't use it.
---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org