2010/8/12 PostgreSQL - Hans-Jürgen Schönig <postgres@cybertec.at>:
> as tom pointed out - this is not possible.
> there is no limit 20 in my case - i just used it to indicate that limiting does not make the index scan possible
whichit does in some other cases.
I came up with this:
explain analyze select * from (select * from t_test order by x limit
all)s order by x, y limit 20;
which uses index scan for column x and top-N heapsort for outer ORDER
BY, though it's slower than "ORDER BY x LIMIT 20" case. If it chooses
external sort for "ORDER BY x, y" LIMIT ALL likely wins while looses
if quicksort is chosen.
Regards,
--
Hitoshi Harada