Re: [PATCHES] Avg performance for int8/numeric

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark Kirkwood <markir(at)paradise(dot)net(dot)nz>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Luke Lonergan <llonergan(at)greenplum(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] Avg performance for int8/numeric
Date: 2006-11-27 00:32:20
Message-ID: 365.1164587540@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Mark Kirkwood <markir(at)paradise(dot)net(dot)nz> writes:
> ... Having said that - the profiles suggest that we are perhaps doing
> a whole lot more alloc'ing (i.e copying? detoasting?) of memory for
> numerics than perhaps we need...

Yeah. We've looked at this in the past and not figured out any
particularly desirable answer for variable-size accumulator state.
There is a hack in there for fixed-size pass-by-reference state (see
count(*)). It's possible that you could get some traction by only doing
a palloc when the state size has to increase --- with a custom state
type it'd be possible to keep track of the allocated size as well as the
actual current length of the numeric sum. Another idea to consider in
this context is avoiding repeated numeric pack/unpack overhead by
storing the running sum in the "calculation variable" format, but I'm
not sure how deep you'd need to burrow into numeric.c to allow that.

Most of this depends on being able to have a transition state value
that isn't any standard SQL datatype. We've discussed that recently
in I-forget-what-context, and didn't find a good answer yet. I think
you can find the thread by searching for a discussion of using type
"internal" as the state datatype --- which is an idea that doesn't work
by itself because of the security holes it'd open in the type system.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Kirkwood 2006-11-27 00:52:46 Re: [PATCHES] Avg performance for int8/numeric
Previous Message Tom Lane 2006-11-27 00:22:51 Re: Missing ParameterStatus for backslash_quote

Browse pgsql-patches by date

  From Date Subject
Next Message Mark Kirkwood 2006-11-27 00:52:46 Re: [PATCHES] Avg performance for int8/numeric
Previous Message Mark Kirkwood 2006-11-26 22:08:54 Re: [PATCHES] Avg performance for int8/numeric