Re: [GENERAL] Sum of multiplied deltas

2009-09-26 Thread Gerhard Wiesinger
Hello, Finally I used a function below which works well. Only one problem is left: It polutes the buffer cache because of the cursor. Any idea to get rid of this behavior? BTW: WINDOWING FUNCTION of 8.4 should help but noone could provide an examples how this could work. Any further comments

Re: [GENERAL] Sum of multiplied deltas

2009-06-09 Thread Martin Gainty
nterdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Subject: Re: [GE

Re: [GENERAL] Sum of multiplied deltas

2009-06-09 Thread Marc Mamin
Hello, I've found a dirty hack with custom GUC variables here: http://archives.postgresql.org/pgsql-hackers/2008-11/msg00643.php Although dirty, it seems that it beats the windowing performances of 8.4. So I wonder if there are any concern about this... Cheers, Marc Mamin -- Sent via pg

Re: [GENERAL] Sum of multiplied deltas

2009-06-08 Thread Daniel Verite
Gerhard Wiesinger wrote: I've the following data: datetime | val1 | val2 time1| 4 | 40% time2| 7 | 30% time3| 12 | 20% ... I'd like to sum up the following: (7-4)*30% + (12-7)*20% + ... datetime is ordered (and unique and has also an id). 1.) Self join with

Re: [GENERAL] Sum of multiplied deltas

2009-06-08 Thread Oliver Kohll - Mailing Lists
On 8 Jun 2009, at 19:01, David Fetter wrote: Hello! I've the following data: datetime | val1 | val2 time1|4 | 40% time2|7 | 30% time3| 12 | 20% ... I'd like to sum up the following: (7-4)*30% + (12-7)*20% + ... This is best done in 8.4 using Windowing. Sadly, it's an

Re: [GENERAL] Sum of multiplied deltas

2009-06-08 Thread Tom Lane
Gerhard Wiesinger writes: > Any hints for an 8.3 environment (currently)? Use a FOR loop in plpgsql and remember the previous row's value in a variable. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subsc

Re: [GENERAL] Sum of multiplied deltas

2009-06-08 Thread Gerhard Wiesinger
Any hints for an 8.3 environment (currently)? Thnx. Ciao, Gerhard -- http://www.wiesinger.com/ On Mon, 8 Jun 2009, David Fetter wrote: On Mon, Jun 08, 2009 at 08:35:20AM +0200, Gerhard Wiesinger wrote: Hello! I've the following data: datetime | val1 | val2 time1|4 | 40% time2

Re: [GENERAL] Sum of multiplied deltas

2009-06-08 Thread David Fetter
On Mon, Jun 08, 2009 at 08:35:20AM +0200, Gerhard Wiesinger wrote: > Hello! > > I've the following data: > datetime | val1 | val2 > time1|4 | 40% > time2|7 | 30% > time3| 12 | 20% > ... > > I'd like to sum up the following: > > (7-4)*30% + (12-7)*20% + ... This is best done i

[GENERAL] Sum of multiplied deltas

2009-06-07 Thread Gerhard Wiesinger
Hello! I've the following data: datetime | val1 | val2 time1|4 | 40% time2|7 | 30% time3| 12 | 20% ... I'd like to sum up the following: (7-4)*30% + (12-7)*20% + ... datetime is ordered (and unique and has also an id). Rows are in the area of millions. How is it done be