Re: [GENERAL] Re : Solaris Performance - Profiling (Solved)

From: mlw <markw(at)mohawksoft(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Doug McNaught <doug(at)wireboard(dot)com>, Justin Clift <justin(at)postgresql(dot)org>, Mark kirkwood <markir(at)slingshot(dot)co(dot)nz>, PostgreSQL Hackers Mailing List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [GENERAL] Re : Solaris Performance - Profiling (Solved)
Date: 2002-04-03 16:32:57
Message-ID: 3CAB2EB9.D6B5967E@mohawksoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Tom Lane wrote:
>
> Doug McNaught <doug(at)wireboard(dot)com> writes:
> > Actually, the C standard says nothing about what algorithm should be
> > used for qsort(); it's simply supposed to be a fast in-memory sort.
> > The qsort() name is just a historical artifact.
>
> In practice I believe qsort usually is a quicksort; it's just too good
> of a general-purpose algorithm. However you do need a good heuristic
> for selecting the median value to split on, or you can get burnt by
> corner cases. I'm guessing that Sun was careless and got burnt ...

quicksort is a pretty poor algorithm if your data is in some kind of order
already. If you are sorting a list that is mostly in the order in which you
want, it will perform very badly indeed. If you could choose the sorting
algorithm based on knowledge of the order of the data, it may improve
performance.

Data retrieved from an index scan is likely to be in some sort of order. If the
order of the data retrieved from an index scan is the same as the order to
which it will be sorted at a later stage of the query, quicksort will probably
be worse than something like shell sort.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-04-03 16:35:30 Re: [HACKERS] Re : Solaris Performance - Profiling (Solved)
Previous Message Jan Wieck 2002-04-03 16:29:38 Re: do foreign key checks lock parent table ?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-04-03 16:35:30 Re: [HACKERS] Re : Solaris Performance - Profiling (Solved)
Previous Message Peter Eisentraut 2002-04-03 16:28:16 Re: Locale support is now on by default