Re: [PATCHES] Avg performance for int8/numeric - Mailing list pgsql-hackers

From Mark Kirkwood
Subject Re: [PATCHES] Avg performance for int8/numeric
Date
Msg-id 4567DB5F.9060900@paradise.net.nz
Whole thread Raw
In response to Re: [PATCHES] Avg performance for int8/numeric  ("Luke Lonergan" <llonergan@greenplum.com>)
Responses Re: [PATCHES] Avg performance for int8/numeric  ("Simon Riggs" <simon@2ndquadrant.com>)
List pgsql-hackers
Luke Lonergan wrote:
> Mark,
> 
> On 11/24/06 6:16 PM, "Mark Kirkwood" <markir@paradise.net.nz> wrote:
> 
>> By way of comparison, here is the first 63 lines for:
>>
>> select sum(val2) from avgtest
> 
> So, sum() is only alloc'ing 5 times for every row being processed, half of
> what avg() is doing.
> 
> Seems like what we need to do is find a way to reuse the temp heaptuple
> between calls.
> 
>

Yeah - and I'm *guessing* that its due to avg needing to 
deconstruct/construct a 2 element numeric array every call (whereas sum 
needs just a single numeric). So some delving into whether it is 
construct_md_array that can re-use a heaptuple or whether we need to 
look elsewhere...

Also Neil suggested investigating using a single composite type {int8, 
numeric} for the {N,sum(X)} transition values. This could well be a 
faster way to do this (not sure how to make it work yet... but it sounds 
promising...).

Cheers

Mark


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: dynahash API questions
Next
From: "Marc G. Fournier"
Date:
Subject: First Release Candidate Uploaded ...