Re: Which qsort is used

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Dann Corbit" <DCorbit(at)connx(dot)com>
Cc: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>, "Greg Stark" <gsstark(at)mit(dot)edu>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, "Luke Lonergan" <llonergan(at)greenplum(dot)com>, "Neil Conway" <neilc(at)samurai(dot)com>, "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Which qsort is used
Date: 2005-12-16 02:24:27
Message-ID: 19345.1134699867@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Dann Corbit" <DCorbit(at)connx(dot)com> writes:
> Radix sort can also be made completely generic by using a callback
> function.
> The function gives back n-bits at a time, from the most significant bits
> to the least significant.

That's mighty handwavy --- it assumes that the datatype permits a simple
breakdown into small pieces that can be sorted lexicographically. Seems
to me that's a much stronger requirement than assuming that you can tell
which of two whole values is smaller. What's worse, it needs to be the
same number of pieces for every value, which makes it hard to deal with
variable-length data.

> So, for char string, and a radix of 256, you just return the first char,
> then the second char, etc. to get the classical radix sort.

Uh, no, you'd need to work right-to-left, after having padded all the
strings to the same length somehow.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Qingqing Zhou 2005-12-16 02:33:08 Re: Which qsort is used
Previous Message Christopher Kings-Lynne 2005-12-16 02:19:56 Re: Improving planning of outer joins