On 08/02/2013 09:37 AM, Vik Fearing wrote:
> EXPLAIN ANALYZE
> WITH RECURSIVE
> x (start_time) AS
> (
> SELECT generate_series(1, 1000000)
> ),
> t (time, timeround) AS
> (
> SELECT time, time - time % 900000 AS timeround
> FROM (SELECT min(start_time) AS time FROM x) AS tmp
> UNION ALL
> SELECT time, time - time % 900000
> FROM (SELECT (SELECT min(start_time) AS time
> FROM x
> WHERE start_time >= t.timeround + 900000)
> FROM t
> WHERE t.time IS NOT NULL OFFSET 0
> ) tmp
> )
> SELECT count(*) FROM t WHERE time IS NOT NULL;
>
> If you remove the OFFSET 0, you'll see two more subplans (because "time"
> is referenced three times).
Is this not interesting to anyone?
Vik