Re: Poor performance using CTE

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Craig Ringer <craig(at)2ndQuadrant(dot)com>, Claudio Freire <klaussfreire(at)gmail(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, David Greco <David_Greco(at)harte-hanks(dot)com>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Poor performance using CTE
Date: 2012-11-21 15:56:01
Message-ID: 50ACF991.3020603@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Heikki Linnakangas 2012-11-21 16:05:17 Re: Hints (was Poor performance using CTE)
Previous Message Gavin Flower 2012-11-21 15:42:16 Re: Poor performance using CTE