Alvaro Herrera <alvherre@commandprompt.com> writes:
> Excerpts from Hans-Jürgen Schönig's message of mié ago 11 08:21:10 -0400 2010:
>> test=# explain analyze select * from t_test order by x, y limit 20;
> But if you put the limit in a subquery which is ordered by the
> known-indexed condition, it is very fast:
> alvherre=# explain analyze select * from (select * from t_test order by x limit 20) f order by x, y;
That's not guaranteed to give you the right 20 rows, though. Consider
the case where there are > 20 rows having the minimal x value.
regards, tom lane