Re: qsort (was Re: Solaris)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: dalgoda(at)ix(dot)netcom(dot)com (Mike Castle)
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: qsort (was Re: Solaris)
Date: 2003-05-08 04:36:32
Message-ID: 17287.1052368592@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

dalgoda(at)ix(dot)netcom(dot)com (Mike Castle) writes:
> In a simple test function, like comparing two ints, then yes, the BSD
> implementation was faster. But in a more complex function, say comparing
> strings, often times the glibc version was faster. Why? Because the
> time spent in the compare function became the overwhelming factor.

Interesting.

> So, I ask you this: in places where qsort is used in PG, is it more likely
> to be used for simple comparisons or for complex comparisons that involve a
> mixture of strings and ints?

The only place that I think performance is likely to matter for is the
calls in tuplesort.c, which are expensive --- even if you end up calling
something as cheap as btint4cmp, there's a lot of overhead in between.
(I seem to recall hearing that Oracle expends effort trying to "compile"
code for tuple comparisons, but we don't ... yet ...)

And, is it more likely to be called with
> datasets that are partially sorted or not?

I think that one's unanswerable. It'd depend on the workload.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dean Gibson (DB Administrator) 2003-05-08 06:31:24 Bug or limitation?
Previous Message Tom Lane 2003-05-08 03:55:23 Re: How to determine a database cluster's LC_COLLATE setting?