Re: Abbreviated keys for Numeric (was: Re: B-Tree support function number 3 (strxfrm() optimization)) - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Abbreviated keys for Numeric (was: Re: B-Tree support function number 3 (strxfrm() optimization))
Date
Msg-id CAM3SWZRU0F_RXu4UC0kcuXE2zrLGi8-jVN-9GT2wEKQMxLSATQ@mail.gmail.com
Whole thread Raw
In response to Abbreviated keys for Numeric (was: Re: B-Tree support function number 3 (strxfrm() optimization))  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Responses Re: Re: Abbreviated keys for Numeric
Re: Re: Abbreviated keys for Numeric
List pgsql-hackers
On Mon, Jan 26, 2015 at 8:43 AM, Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
> Another spinoff from the abbreviation discussion. Peter Geoghegan
> suggested on IRC that numeric would benefit from abbreviation, and
> indeed it does (in some cases by a factor of about 6-7x or more, because
> numeric comparison is no speed demon).

Cool.

What I find particularly interesting about this patch is that it makes
sorting numerics significantly faster than even sorting float8 values,
at least some of the time, even though the latter has generic
SortSupport (for fmgr elision). Example:

postgres=# create table foo as select x::float8 x, x::numeric y from
(select random() * 10000000 x from generate_series(1,1000000) a) b;
SELECT 1000000

This query takes about 525ms after repeated executions:      select *
from (select * from foo order by x offset 1000000000) i;

However, this query takes about 412ms:
select * from (select * from foo order by y offset 1000000000) i;

There is probably a good case to be made for float8 abbreviation
support....just as well that your datum abbreviation patch doesn't
imply that pass-by-value types cannot be abbreviated across the board
(it only implies that abbreviation of pass-by-value types is not
supported in the datum sort case).    :-)

Anyway, the second query above (the one with the numeric ORDER BY
column) is enormously faster than the same query executed against
master's tip. That takes about 1720ms following repeated executions.
So at least that case is over 4x faster, suggesting that abbreviation
support for numeric is well worthwhile. So I'm signed up to review
this one too.
-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: New CF app deployment
Next
From: Josh Berkus
Date:
Subject: Re: New CF app deployment