Re: Which qsort is used

Поиск
Список
Период
Сортировка
От Marko Kreen
Тема Re: Which qsort is used
Дата
Msg-id e51f66da0512130144i47623e1ftc67ecc76560ae543@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Which qsort is used  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: Which qsort is used  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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
behavesbetter." 

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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Michael Paesold"
Дата:
Сообщение: Re: Anyone for adding -fwrapv to our standard CFLAGS?
Следующее
От: Mario Weilguni
Дата:
Сообщение: Deadlock with ShareLocks?