Re: Sorting Improvements for 8.4 - Mailing list pgsql-hackers

From Sam Mason
Subject Re: Sorting Improvements for 8.4
Date
Msg-id 20071128153010.GV1955@frubble.xen.chris-lamb.co.uk
Whole thread Raw
In response to Sorting Improvements for 8.4  (Simon Riggs <simon@2ndquadrant.com>)
List pgsql-hackers
On Tue, Nov 27, 2007 at 06:03:46PM +0000, Simon Riggs wrote:
> Just wanted to review a few thoughts and ideas around improving external
> sorts, as recently encouraged to do by Jim Nasby. 

Is there any way of PG knowing that having an index on a subset of the
sorted columns is sometimes a win?  For example, if we have:
 CREATE TABLE foo (   a INTEGER NOT NULL PRIMARY KEY,   b INTEGER NOT NULL,   c INTEGER );

and we request:
 SELECT * FROM foo ORDER BY a,b LIMIT 10;

then it may be a win to do smaller sorts for each value of "a", rather
than one big sort after all the data has been pulled out.  Obviously,
it would depend on the distribution of "a", large numbers of distinct
values for "a" being good, and a small number being bad.

I think this would help in a number of other situations as well, but
that's just the most obvious case.

 Sam


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: pgwin32_open returning EINVAL
Next
From: Louis-David Mitterrand
Date:
Subject: 8.3beta3 ERROR: cached plan must not change result type