From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Peter Geoghegan <peter(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <stark(at)mit(dot)edu>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Inlining comparators as a performance optimisation |
Date: | 2011-11-18 22:08:18 |
Message-ID: | 20111118220818.GA5353@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Nov 18, 2011 at 12:20:26AM -0500, Robert Haas wrote:
> I think that we should really consider doing with this patch what Tom
> suggested upthread; namely, looking for a mechanism to allow
> individual datatypes to offer up a comparator function that doesn't
> require bouncing through FunctionCall2Coll(). It seems to me that
> duplicating the entire qsort() algorithm is a little iffy. Sure, in
> this case it works out to a win. But it's only a small win -
> three-quarters of it is in the uncontroversial activity of reducing
> the impedance mismatch - and how do we know it will always be a win?
There's always the old idea of a data type providing a function mapping
f:(type -> int64) in such a way that it preserves order. That is, in the
sense that:
f(x) < f(y) => x < y
When sorting, you add f(x) as hidden column and change "ORDER BY x" to
"ORDER BY f(x), x". Then you only need to special case the int64
version. This would mean that in most cases you may be able to skip
the call because you're comparing integers. The downside is you need
to call f on each input. It depends on the datatype if that's cheaper
or not, but for all numerics types I think it's an easy win.
I don't think anyone has written a proof of concept for this. It does
have the advantage of scaling better than coding a qsort for each
individual type.
Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.
-- Arthur Schopenhauer
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2011-11-18 22:12:02 | Re: testing ProcArrayLock patches |
Previous Message | Kevin Grittner | 2011-11-18 22:06:00 | Re: Materialized views |