On Wed, Oct 14, 2009 at 4:50 PM, Tim Landscheidt
wrote:
> Peter Hunsberger wrote:
>
> After some tests with a data set of 7983 rows (and 1638 ran-
> ges): Don't! :-) The recursive solution seems to be more
> than double as slow as the iterative. I'll take it to -per-
> formance.
>
Interesting,
Peter Hunsberger wrote:
> [...]
>> or a recursive query (which I always find very hard to com-
>> prehend):
>> | WITH RECURSIVE RecCols (LeftBoundary, Value) AS
>> | (SELECT col, col FROM t WHERE (col - 1) NOT IN (SELECT col FROM t)
>> | UNION ALL SELECT p.LeftBoundary, c.col FROM RecCols A
On Tue, Oct 13, 2009 at 5:12 PM, Tim Landscheidt
wrote:
> Peter Hunsberger wrote:
>
> You can either use a PL/pgSQL function ("SETOF TEXT" just
> for the convenience of the example):
That works well, takes about 20 seconds to do the 6M+ rows
>
> or a recursive query (which I always find very h
Peter Hunsberger wrote on 13.10.2009 23:23:
I need a query to find the contiguous ranges within this column, in
this case returning the result set:
start, end
2, 5
11, 19
23, 23
32, 37
I have one solution that joins the table against itself and does
(among other things) a subselect looking "not
Peter Hunsberger wrote:
> [...]
> I have one solution that joins the table against itself and does
> (among other things) a subselect looking "not exists col +1" and "not
> exists col -1" on the two instances of the table to find the start and
> end. This is, as you might guess, is not very effi
Given a column of data resembling the following:
col
2
3
4
5
11
12
13
14
15
16
17
18
19
23
32
33
34
35
36
37
I need a query to find the contiguous ranges within this column, in
this case returning the result set:
start, end
2, 5
11, 19
23, 23
32, 37
I have one solution that joins the table agai