Re: Sort Refinement - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: Sort Refinement
Date
Msg-id 1206190759.4285.756.camel@ebony.site
Whole thread Raw
In response to Re: Sort Refinement  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-hackers
On Thu, 2008-03-20 at 22:35 +0000, Gregory Stark wrote:
> "Simon Riggs" <simon@2ndquadrant.com> writes:
> 
> > If we assume we use heap sort, then if we *know* that the data is
> > presorted on (a) then we should be able to emit tuples directly that the
> > value of (a) changes and keep emitting them until the heap is empty,
> > since they will exit the heap in (a,b) order.
> 
> Actually, I would think the way to do this would be to do a quicksort if you
> find you've accumulated all the records in a subgroup in memory. One easy way
> to do it would be to have nodeSort build a new tuplesort for each subgroup if
> it has a level break key parameter set (memories of RPG III are coming
> bubbling to the surface).

Yes, its essentially the same thing as running a series of otherwise
unconnected sorts. However, that seems to introduce its own overheads if
we did that literally.

We needn't fix this to either a heapsort or a quicksort. We can let the
existing code decide which and let the mode change naturally from one to
the other as is needed.

--  Simon Riggs 2ndQuadrant  http://www.2ndQuadrant.com 
 PostgreSQL UK 2008 Conference: http://www.postgresql.org.uk



pgsql-hackers by date:

Previous
From: Shane Ambler
Date:
Subject: Re: serial arrays?
Next
From: Simon Riggs
Date:
Subject: Re: Sort Refinement