Re: [HACKERS] CTE inlining - Mailing list pgsql-hackers

From Andreas Karlsson
Subject Re: [HACKERS] CTE inlining
Date
Msg-id 19fe51b0-1d0b-a72c-99ee-aacb5b4930f8@proxel.se
Whole thread Raw
In response to Re: [HACKERS] CTE inlining  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
Responses Re: [HACKERS] CTE inlining  (Craig Ringer <craig.ringer@2ndquadrant.com>)
List pgsql-hackers
On 05/04/2017 06:22 PM, Andrew Dunstan wrote:
> I wrote this query:
>
>     select (json_populate_record(null::mytype, myjson)).*
>     from mytable;
>
>
> It turned out that this was an order of magnitude faster:
>
>     with r as
>     (
>        select json_populate_record(null::mytype, myjson) as x
>        from mytable
>     )
>     select (x).*
>     from r;

I do not know the planner that well, but I imagined that when we remove 
the optimization fence that one would be evaluated similar to if it had 
been a lateral join, i.e. there would be no extra function calls in this 
case after removing the fence.

Andreas



pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: [HACKERS] WIP Patch: Precalculate stable functions,infrastructure v1
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] what's up with IDENTIFIER_LOOKUP_EXPR?