Re: Sort Refinement

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Sort Refinement
Date: 2008-03-22 12:59:19
Message-ID: 1206190759.4285.756.camel@ebony.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 2008-03-20 at 22:35 +0000, Gregory Stark wrote:
> "Simon Riggs" <simon(at)2ndquadrant(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2008-03-22 13:01:07 Re: Sort Refinement
Previous Message Shane Ambler 2008-03-22 08:17:39 Re: serial arrays?