"Gurjeet Singh" <[EMAIL PROTECTED]> writes: > On Sun, May 11, 2008 at 11:47 PM, Craig Ringer <[EMAIL PROTECTED]> >> If you cannot assume that, you can use a subquery with limit and order >> by to obtain the next record: >> >> SELECT >> a.ts, >> (SELECT b.size FROM x b WHERE b.ts > a.ts ORDER BY b.ts ASC LIMIT 1) >> - a.size AS difference >> FROM x a; >> >> ... but that'll be really slow for any significant number of entries.
> not really... if you have an index on the TS column. The OP said this was a view, so it may well not have any easy way to provide such an index. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql