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

From Mark Lewis
Subject Re: qsort again (was Re: [PERFORM] Strange Create Index
Date
Msg-id 1140197437.9076.268.camel@archimedes
Whole thread Raw
In response to Re: qsort again (was Re: [PERFORM] Strange Create Index  (David Lang <dlang@invendra.net>)
Responses Re: qsort again (was Re: [PERFORM] Strange Create Index  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Thu, 2006-02-16 at 21:33 -0800, David Lang wrote:
> > In SQL_ASCII, just take the first 4 characters (or 8, if using a 64-bit
> > sortKey as elsewhere suggested).  The sorting key doesn't need to be a
> > one-to-one mapping.
>
> that would violate your second contraint ( f(a)==f(b) iff (a==b) )
>
> if you could drop that constraint (the cost of which would be extra 'real'
> compares within a bucket) then a helper function per datatype could work
> as you are talking.

I think we're actually on the same page here; you're right that the
constraint above ( f(a)==f(b) iff a==b ) can't be extended to data types
with more than 32 bits of value space.  But the constraint I listed was
actually:

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

Which doesn't imply 'if and only if'.  It's a similar constraint to
hashcodes; the same value will always have the same hash, but you're not
guaranteed that the hashcodes for two distinct values will be unique.

-- Mark

pgsql-hackers by date:

Previous
From: "Michael Paesold"
Date:
Subject: Re: Need pointers to "standard" pg database(s) for testing
Next
From: Ragnar
Date:
Subject: Re: qsort again (was Re: [PERFORM] Strange Create