From: | Justin <justin(at)emproshunts(dot)com> |
---|---|
To: | Justin <justin(at)emproshunts(dot)com>, btober(at)ct(dot)metrocast(dot)net, pgsql-general(at)postgresql(dot)org |
Subject: | Re: how do you write aggregate function |
Date: | 2008-03-10 15:01:47 |
Message-ID: | 47D54D5B.5030301@emproshunts.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
i wish that could work but need to keep track of the individual weights
as its a percentage of the total amount of the weight.
I would never have thought the performance of the Array would suck this
bad.
Martijn van Oosterhout wrote:
> On Sun, Mar 09, 2008 at 11:40:47AM -0500, Justin wrote:
>
>> I got the aggregate function for weighted average done. I finely left
>> alone for more than 10 minutes to actual get it written. It takes 2
>> value input Weight and the Value. it will sum the weighted entries to
>> create the constant then does the normal formula, but does not
>> percentage number but averaged number. A simple change on the return
>> line it can do percentages.
>>
>
> If you're looking for performance, ISTM the best option would be to
> simply accumulate the weights and value*weight as you go and do a
> division at the end. That seems likely to beat any implementation
> involving array_append.
>
> Have a nice day,
>
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Smith | 2008-03-10 15:02:08 | Re: my problem for i/o error when i use postgre |
Previous Message | Chris Browne | 2008-03-10 14:42:07 | Re: PostreSQL Single File ( Like M$ Access) |