Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V7YOa-00041S-FH for pgsql-performance@arkaria.postgresql.org; Thu, 08 Aug 2013 22:09:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V7YOZ-00026y-M1 for pgsql-performance@arkaria.postgresql.org; Thu, 08 Aug 2013 22:09:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V7YOY-00026r-KH for pgsql-performance@postgresql.org; Thu, 08 Aug 2013 22:09:22 +0000 Received: from mimolette.dalibo.net ([212.85.154.222]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V7YOW-0003Vb-9n for pgsql-performance@postgresql.org; Thu, 08 Aug 2013 22:09:22 +0000 Received: from [192.168.0.38] (ip-68.net-81-220-133.standre.rev.numericable.fr [81.220.133.68]) by mimolette.dalibo.net (Postfix) with ESMTPSA id 525684501C2D; Fri, 9 Aug 2013 00:09:18 +0200 (CEST) Message-ID: <5204170D.4020608@dalibo.com> Date: Fri, 09 Aug 2013 00:09:17 +0200 From: Vik Fearing User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 MIME-Version: 1.0 To: Scott Marlowe CC: Tom Lane , "pgsql-performance@postgresql.org" Subject: Re: subselect requires offset 0 for good performance. References: <4522.1375400642@sss.pgh.pa.us> <51FB61C8.4090206@dalibo.com> In-Reply-To: <51FB61C8.4090206@dalibo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org 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 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance