Re: subselect requires offset 0 for good performance.

From: Vik Fearing <vik(dot)fearing(at)dalibo(dot)com>
To: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: subselect requires offset 0 for good performance.
Date: 2013-08-08 22:09:17
Message-ID: 5204170D.4020608@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Robert DiFalco 2013-08-08 22:21:31 Re: Efficient Correlated Update
Previous Message Claudio Freire 2013-08-08 20:08:52 Re: Efficiently query for the most recent record for a given user