Re: qsort again (was Re: [PERFORM] Strange Create Index

Mark Lewis <mark.lewis@mir3.com>

From: Mark Lewis <mark.lewis@mir3.com>
To: David Lang <dlang@invendra.net>
Cc: Greg Stark <gsstark@mit.edu>, Markus Schaber <schabi@logix-tt.com>, pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org
Date: 2006-02-17T17:30:37Z
Lists: pgsql-hackers, pgsql-performance
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