Re: Very specialised query - Mailing list pgsql-performance

From Dimitri Fontaine
Subject Re: Very specialised query
Date
Msg-id 945DB222-5D3B-466A-80D1-50563B12A407@hi-media.com
Whole thread Raw
In response to Very specialised query  (Matthew Wakeling <matthew@flymine.org>)
Responses Re: Very specialised query  (Matthew Wakeling <matthew@flymine.org>)
List pgsql-performance
Hi,

Le 26 mars 09 à 15:30, Matthew Wakeling a écrit :
> Now, it happens that there is an algorithm for calculating overlaps
> which is really quick. It involves iterating through the table in
> order of the start variable and keeping a list of ranges which
> "haven't ended yet". When you read the next range from the table,
> you firstly purge all the ranges from the list that end before the
> beginning of the new range. Then, you output a result row for each
> element in the list combined with the new range, then you add the
> new range to the list.
>
> This algorithm just doesn't seem to fit into SQL at all.

Maybe it's just that I didn't devote enough time to reading your
detailed explanation above, but this part sounds like it could be done
in an aggregate you'd use in a correlated subquery containing the
right ORDER BY, couldn't it?
   http://www.postgresql.org/docs/8.3/interactive/sql-createaggregate.html

HTH,
--
dim




pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Very specialised query
Next
From: David Rees
Date:
Subject: Re: I have a fusion IO drive available for testing