Re: Reusing abbreviated keys during second pass of ordered [set] aggregates

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Reusing abbreviated keys during second pass of ordered [set] aggregates
Date: 2015-09-26 19:16:40
Message-ID: CAM3SWZSzTy2zfsMXqqQbhiyAYALdt-i99FqWNcy-4LZpcWL6Ow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Sep 6, 2015 at 9:35 PM, Thomas Munro
<thomas(dot)munro(at)enterprisedb(dot)com> wrote:
> Running various contrived aggregate queries on a large low cardinality
> dataset in a small range (therefore frequently the same weight & size), I
> managed to measure a small improvement of up to a few percent with the
> attached patch. I also wonder whether numeric_cmp could be profitably
> implemented with memcmp on big endian systems and some unrolled loops on
> little endian systems when size & weight match.

I think that setting up numeric SortSupport to have scratch memory
used across authoritative numeric comparator calls would also help.

We should prefer to do this kind of thing in a datatype independent
way, of course. I'm not opposed to doing what you outline too, but I
don't think it will be especially helpful for the cases here. I think
that what you're talking about would live in the SortSupport
authoritative comparator, and would benefit non-leading-attribute
comparisons most.

> Of course there are a ton of other overheads involved with numeric. I
> wonder how crazy or difficult it would be to make it so that we could
> optionally put a pass-by-value NUMERIC in a Datum, setting a low order tag
> bit to say 'I'm an immediate value, not a pointer', and then packing 3
> digits (= 12 significant figures) + sign + weight into the other 63 bits.

That seems possible, but very invasive. I'd want to get a good sense
of the pay-off before undertaking such a project.

--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-09-26 20:09:12 Re: Parallel Seq Scan
Previous Message Tom Lane 2015-09-26 17:52:44 Re: Rework the way multixact truncations work