Re: qsort again (was Re: [PERFORM] Strange Create Index - Mailing list pgsql-hackers

From Markus Schaber
Subject Re: qsort again (was Re: [PERFORM] Strange Create Index
Date
Msg-id 43F4FDCC.2000204@logix-tt.com
Whole thread Raw
In response to Re: qsort again (was Re: [PERFORM] Strange Create Index  (Mark Lewis <mark.lewis@mir3.com>)
Responses Re: qsort again (was Re: [PERFORM] Strange Create Index
List pgsql-hackers
Hi, Mark,

Mark Lewis schrieb:

> It seems that instead of maintaining a different sorting code path for
> each data type, you could get away with one generic path and one
> (hopefully faster) path if you allowed data types to optionally support
> a 'sortKey' interface by providing a function f which maps inputs to 32-
> bit int outputs, such that the following two properties hold:
>
> f(a)>=f(b) iff a>=b
> if a==b then f(a)==f(b)

Hmm, to remove redundancy, I'd change the <= to a < and define:

if a==b then f(a)==f(b)
if a<b  then f(a)<=f(b)

> Data types which could probably provide a useful function for f would be
> int2, int4, oid, and possibly int8 and text (at least for SQL_ASCII).

With int2 or some restricted ranges of oid and int4, we could even
implement a bucket sort.

Markus

pgsql-hackers by date:

Previous
From: Mark Lewis
Date:
Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index
Next
From: Martijn van Oosterhout
Date:
Subject: Re: qsort again (was Re: [PERFORM] Strange Create Index