Re: obtain the difference between successive rows - Mailing list pgsql-general

From Tom Lane
Subject Re: obtain the difference between successive rows
Date
Msg-id 29633.1350750214@sss.pgh.pa.us
Whole thread Raw
In response to Re: obtain the difference between successive rows  (Chris Angelico <rosuav@gmail.com>)
Responses Re: obtain the difference between successive rows  (Raymond O'Donnell <rod@iol.ie>)
List pgsql-general
Chris Angelico <rosuav@gmail.com> writes:
> To be quite honest, I would simply read the table directly and then do
> the processing in an application language :) But two window functions
> should do the trick. Whether or not it's actually more efficient that
> way is another question.

FWIW, Postgres is reasonably smart about the case of multiple window
functions with identical window definitions --- once you've got one
lag() in the query, adding more isn't going to cost much.

Having said that, they are pretty expensive.  I tend to agree that doing
the processing on the application side might be faster --- but only if
you've got a place to put such code there.  If you've just got generic
query-result display code, there may not be any convenient way to do it.

            regards, tom lane


pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: obtain the difference between successive rows
Next
From: Raymond O'Donnell
Date:
Subject: Re: obtain the difference between successive rows