Re: CTE inlining

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Serge Rielau <serge(at)rielau(dot)com>
Cc: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>, Craig Ringer <craig(dot)ringer(at)2ndquadrant(dot)com>, Ilya Shkuratov <motr(dot)ilya(at)ya(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Mario Becroft <mb(at)true(dot)group>
Subject: Re: CTE inlining
Date: 2017-05-04 22:04:46
Message-ID: 19fe51b0-1d0b-a72c-99ee-aacb5b4930f8@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-05-04 22:05:18 Re: what's up with IDENTIFIER_LOOKUP_EXPR?
Previous Message Alexander Korotkov 2017-05-04 22:02:08 Re: WIP Patch: Precalculate stable functions, infrastructure v1