On 12/12/05, Bruce Momjian <pgman@candle.pha.pa.us> wrote:
> Qingqing Zhou wrote:
> > Seems we don't link against the port/qsort.c - is there any reason for
> > that? My tests indicates our qsort is much much faster than the libc's.

> Are you willing to say that we should always prefer pgport over glibc's
> qsort()?

I searched the archives and found this:

http://sourceware.org/ml/libc-alpha/2000-03/msg00139.html

Seems glibc guys once tested some implementation of quicksort vs. merge sort
and found out that

   "For small sets and smaller data types (arrays of ints and
   arrays of doubles) mergesort is definitly faster and behaves better."

If the qsort in Postgres is called usually on wide data - on full rows
not on pointers to rows, then indeed it would be wise to use out own
sort. Especially considering that qsort is not anything OS or machine
-specific, better algorithm beats assembly-optimizations. If we have
a very good good implementation we could use it everywhere.

OTOH, someone should notify glibc devs that their qsort is mediocre,
I don't see much activity on the lists around around that topic.

--
marko

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to