Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fY3vG-0003Fn-UV for pgsql-general@arkaria.postgresql.org; Wed, 27 Jun 2018 06:27:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fY3vE-0004Xr-P9 for pgsql-general@arkaria.postgresql.org; Wed, 27 Jun 2018 06:27:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fY3vE-0004Xk-Fd for pgsql-general@lists.postgresql.org; Wed, 27 Jun 2018 06:27:20 +0000 Received: from mail-io0-x22b.google.com ([2607:f8b0:4001:c06::22b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fY3vA-0000dS-Vy for pgsql-general@lists.postgresql.org; Wed, 27 Jun 2018 06:27:19 +0000 Received: by mail-io0-x22b.google.com with SMTP id k16-v6so809014ioa.8 for ; Tue, 26 Jun 2018 23:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=92rz/XfaFEPsV9AWkYBpYRfhjyIjOot3wmLSJV91aao=; b=JMaFmRh7i/Ls+LBRnZc3o1Byx0Fs7IUaKoIFSsEl6LXCUhTRhLjwEZKBCQxRr0MPGj tOWBnm+LSf9r6YDEFu7ut7vA+E1xENaqwOVeZu+fPihQoWQTq8v41sbLFRrTb6e3eUgH BCTX4G/w6uQVYPvr9/BVh137bSHeQ8B/h7cjJlvecEVGejqc7hsmHXCI/Hjk3/Iz09gu InrIqctsI/6bxM77Z0ifQJfxZHKh8zFjIoLFY0StX7sopqmEqP/tr7kCGpeQpQCOKTSX nn99LsyPHMlw8lNF6u/u4rFacMQusini5vtySqNytsDf3MtsNWK32+zvEAS+vZkyFzJl ZGdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=92rz/XfaFEPsV9AWkYBpYRfhjyIjOot3wmLSJV91aao=; b=iufqL6d5KZfjdwljqh5lxuHqFR5xzqvpYMU2xI6SH9/QpHEQBUwxMaFnbPfpj4CKTs yuM4AisO3T3y6e/GF9Re0y6k3IZYjT9E7DAfQVP0KpTHZDxmFR6NZ+J6Yq39pW6oYePD XkFQ5lSmo2bIrSDY59mHgb4OViJIUiUYqtkVTdBK2v+mnbYyucqxf7at1Fj48U6bKazS 9BpZNR+cWjWE4X9QblePgKE6VkP4vWbItdGjjUUGqw1HzCvey1raQOQ0Tq4el7baFGWZ O9oIdE96Z9AtRX798F39HLu9cg5f/qSfDX/qmf4BtWzabfMaYAYIvvdvSHX4BpYKglpK h9wQ== X-Gm-Message-State: APt69E03kWHGn+Qc6Fct1bEx0IAoyGgJqDYWhJgPWswAdapSmt5384fX mzIYTwfHwz7dv4rQuYgRm+ahBpvF X-Google-Smtp-Source: AAOMgpdRhGirYpolzL+cERmv5pAd3p0fd+kRE6Xsk7tbYZm50wkLoYIdRo0/5IuRpo1TofYeECxSYQ== X-Received: by 2002:a6b:bf86:: with SMTP id p128-v6mr3785822iof.76.1530080834688; Tue, 26 Jun 2018 23:27:14 -0700 (PDT) Received: from [10.0.0.10] (c-98-202-193-197.hsd1.ut.comcast.net. [98.202.193.197]) by smtp.gmail.com with ESMTPSA id 80-v6sm1912851itk.12.2018.06.26.23.27.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jun 2018 23:27:14 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: CTE optimization fence From: Rob Sargent X-Mailer: iPhone Mail (15F79) In-Reply-To: Date: Wed, 27 Jun 2018 00:27:13 -0600 Cc: pgsql-general@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <31DF665F-B3D6-4D2E-A3C1-53C4E869BB1B@gmail.com> References: <23733.1530071303@sss.pgh.pa.us> To: Thomas Kellerer List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I don=E2=80=99t think the fence analogy works. Try wall (a la Berlin).=20 I count myself amongst those who thought =E2=80=9COoh this little CTE will g= arner just what the rest of the query needs=E2=80=9D. Only to find the plann= er didn=E2=80=99t groc that optimization.=20 Is it a matter of deciding to trust the SQLer and runtime analyzing the CTE p= roduct before continuing? As an SQLer I have doubts about that precept but w= ithout _some_ change in attack CTEs approach fluff.=20 > On Jun 26, 2018, at 11:45 PM, Thomas Kellerer wrote: >=20 > Tom Lane schrieb am 27.06.2018 um 05:48: >>> I see there was some discussion last year about removing the CTE=20 >>> optimization fence (e.g.=20 >>> http://www.postgresql-archive.org/CTE-inlining-td5958992.html) but can't= =20 >>> find anything more recent. Does anyone know if this is still under=20 >>> consideration? >>=20 >> but we have to settle on a way of controlling it. >=20 > +1 from me.=20 >=20 > I am running more and more into situations where people consider this a bu= g rather than a feature. >=20 > FWIW, I think a GUC that switches between the current (mostly unwanted, at= least surprising)=20 > way and one where the CTE is optimized together with the main query would s= uit "most" people. >=20 > For sake of compatibility this could default to the current behaviour >=20