Hi,
Hans-Juergen Schoenig wrote:
> in fact, the sort step is not necessary here as we could add a node
> which buffers the highest 10 records and replaces them whenever a
> higher value is returned from the underlaying node (in this case seq scan).
> this query is a quite common scenario when it comes to some analysis
> related issues.
> saving the sort step is an especially good idea when the table is very
> large.
That sounds very much like what's known as 'partial sort', which has
been proposed by Oleg and Theodor. AFAIK they had a trivial patch
sometime around version 7.1, without integration into the planer and
optimizer. They were talking about libpsort, but I can't find that
currently. See archives [1] and [2].
Regards
Markus
[1]: http://archives.postgresql.org/pgsql-sql/2002-01/msg00316.php
[2]: http://archives.postgresql.org/pgsql-hackers/2006-09/msg01532.php