Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TbCem-0006Tq-T8 for pgsql-performance@postgresql.org; Wed, 21 Nov 2012 15:56:09 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TbCek-0002YI-H2 for pgsql-performance@postgresql.org; Wed, 21 Nov 2012 15:56:08 +0000 Received: from sc9-mailhost1.vmware.com (sc9-mailhost1.vmware.com [10.113.161.71]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 5975A2844E; Wed, 21 Nov 2012 07:56:05 -0800 (PST) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 546CC1855B; Wed, 21 Nov 2012 07:56:05 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id E4D49121586; Wed, 21 Nov 2012 07:56:43 -0800 (PST) X-Virus-Scanned: amavisd-new at zcs-prod-ext-mta-1.vmware.com Received: from zcs-prod-ext-mta-1.vmware.com ([127.0.0.1]) by localhost (zcs-prod-ext-mta-1.vmware.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3daFpkbQaTRJ; Wed, 21 Nov 2012 07:56:43 -0800 (PST) Received: from [192.168.1.90] (unknown [10.113.62.14]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA id B247D121561; Wed, 21 Nov 2012 07:56:41 -0800 (PST) Message-ID: <50ACF991.3020603@vmware.com> Date: Wed, 21 Nov 2012 17:56:01 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.10) Gecko/20121027 Icedove/10.0.10 MIME-Version: 1.0 To: Gavin Flower CC: Andres Freund , Andrew Dunstan , Tom Lane , Craig Ringer , Claudio Freire , Merlin Moncure , David Greco , "pgsql-performance@postgresql.org" Subject: Re: Poor performance using CTE References: <50AC1472.3050607@2ndQuadrant.com> <18123.1353455585@sss.pgh.pa.us> <50ACD166.1000507@vmware.com> <50ACE970.7050701@dunslane.net> <3396.1353509947@sss.pgh.pa.us> <50ACF16C.2020902@dunslane.net> <20121121153209.GA1271@awork2.anarazel.de> <50ACF658.10902@archidevsys.co.nz> In-Reply-To: <50ACF658.10902@archidevsys.co.nz> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -7.2 (-------) X-Archive-Number: 201211/230 X-Sequence-Number: 48596 On 21.11.2012 17:42, Gavin Flower wrote: > On 22/11/12 04:32, Andres Freund wrote: >> On 2012-11-21 10:21:16 -0500, Andrew Dunstan wrote: >>> I wasn't talking about removing it. My point was that if the >>> optimization >>> fence around CTEs is removed a lot of people will need to rework apps >>> where >>> they have used them for that purpose. And I continue to think that >>> spelling >>> it "OFFSET 0" is horribly obscure. >> +1 FWIW, I'm happy with "OFFSET 0". Granted, it's pretty obscure, but that's what we've historically recommended, and it's pretty ugly to have to specify a fence like that in the first place. Whenever you have to resort to it, you ought have a comment in the query explaining why you need to force the planner like that, anyway. >> WITH foo AS (SELECT ...) (barrier=on|off)? >> >> 9.3 introduces the syntax, defaulting to on >> 9.4 switches the default to off. > > WITH foo AS (SELECT ...) (fence=on|off)? > > WITH foo AS (SELECT ...) (optimisation_fence=on|off)? If we are to invent a new syntax for this, can we please come up with something that's more widely applicable than just the WITH syntax. Something that you could use to replace OFFSET 0 in a subquery, too. - Heikki