Re: "micro bucket sort" ...

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: PostgreSQL - Hans-Jürgen Schönig <postgres(at)cybertec(dot)at>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, PGSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: "micro bucket sort" ...
Date: 2010-08-13 14:09:11
Message-ID: AANLkTik2=Uo5uL4pHmXC6rcsZgXOfZHqp7=OjEesgoFX@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2010/8/12 PostgreSQL - Hans-Jürgen Schönig <postgres(at)cybertec(dot)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 which it 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-08-13 14:46:10 Re: patch: General purpose utility functions used by the JSON data type
Previous Message Robert Haas 2010-08-13 13:32:27 Re: Develop item from TODO list