Re: Optimizing "top queries" ... - Mailing list pgsql-hackers

From Markus Schiltknecht
Subject Re: Optimizing "top queries" ...
Date
Msg-id 4576A195.4010901@bluegap.ch
Whole thread Raw
In response to Optimizing "top queries" ...  (Hans-Juergen Schoenig <postgres@cybertec.at>)
Responses Re: Optimizing "top queries" ...  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Hans-Juergen Schoenig
Date:
Subject: Optimizing "top queries" ...
Next
From: Hubert FONGARNAND
Date:
Subject: Bug in PostGreSQL 8.2