Re: qsort again

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Florian Weimer <fw(at)deneb(dot)enyo(dot)de>
Cc: Neil Conway <neilc(at)samurai(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gary Doades <gpd(at)gpdnet(dot)co(dot)uk>, pgsql-performance(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: qsort again
Date: 2006-02-16 12:49:18
Message-ID: 20060216124918.GE26127@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

On Thu, Feb 16, 2006 at 01:10:48PM +0100, Florian Weimer wrote:
> * Neil Conway:
>
> > On Wed, 2006-02-15 at 18:28 -0500, Tom Lane wrote:
> >> It seems clear that our qsort.c is doing a pretty awful job of picking
> >> qsort pivots, while glibc is mostly managing not to make that mistake.
> >> I haven't looked at the glibc code yet to see what they are doing
> >> differently.
> >
> > glibc qsort is actually merge sort, so I'm not surprised it avoids this
> > problem.
>
> qsort also performs twice as many key comparisons as the theoretical
> minimum. If key comparison is not very cheap, other schemes (like
> heapsort, for example) are more attractive.

Last time around there were a number of different algorithms tested.
Did anyone run those tests while getting it to count the number of
actual comparisons (which could easily swamp the time taken to do the
actual sort in some cases)?

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sven Geisler 2006-02-16 13:08:40 Re: [PERFORM] qsort again
Previous Message Martijn van Oosterhout 2006-02-16 12:45:56 Re: Doubt in parser

Browse pgsql-performance by date

  From Date Subject
Next Message Sven Geisler 2006-02-16 13:08:40 Re: [PERFORM] qsort again
Previous Message Florian Weimer 2006-02-16 12:10:48 Re: qsort again