Re: [HACKERS] qsort again (was Re: Strange Create Index - Mailing list pgsql-performance

From PFC
Subject Re: [HACKERS] qsort again (was Re: Strange Create Index
Date
Msg-id op.s42829s9cigqcu@apollo13
Whole thread Raw
In response to Re: [HACKERS] qsort again (was Re: Strange Create Index  (Mark Lewis <mark.lewis@mir3.com>)
Responses Re: [HACKERS] qsort again (was Re: Strange Create Index
Re: [HACKERS] qsort again (was Re: Strange Create Index
List pgsql-performance

> 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:

    Looks like the decorate-sort-undecorate pattern, which works quite well.
Good idea.
    I would have said a 64 bit int, but it's the same idea. However it won't
work for floats, which is a pity, because floats fit in 64 bits. Unless
more types creep in the code path (which would not necessarily make it
that slower).
    As for text, the worst case is when all strings start with the same 8
letters, but a good case pops up when a few-letter code is used as a key
in a table. Think about a zipcode, for instance. If a merge join needs to
sort on zipcodes, it might as well sort on 64-bits integers...

    By the way, I'd like to declare my zipcode columns as SQL_ASCII while the
rest of my database is in UNICODE, so they are faster to index and sort.
Come on, MySQL does it...

    Keep up !

pgsql-performance by date:

Previous
From: Greg Stark
Date:
Subject: Re: [HACKERS] qsort again (was Re: Strange Create Index
Next
From: Mark Lewis
Date:
Subject: Re: [HACKERS] qsort again (was Re: Strange Create Index