Re: Alias of VALUES RTE in explain plan

From: Yasir <yasir(dot)hussain(dot)shah(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Alias of VALUES RTE in explain plan
Date: 2024-10-27 20:03:14
Message-ID: CAA9OW9cL+d-uDA9OxcvLTRnqtVdgFq4A_rVdjtQp_bcAWhjbiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Oct 26, 2024 at 12:21 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> I wrote:
> > However ... I don't like this implementation, not even a little
> > bit.
>
> I forgot to mention a third problem, which is that reassigning the
> alias during subquery pullup means it doesn't happen if subquery
> pullup doesn't happen. As an example, with your patch:
>
> regression=# explain verbose select * from (values (1), (2)) v(x);
> QUERY PLAN
> ----------------------------------------------------
> Values Scan on v (cost=0.00..0.03 rows=2 width=4)
> Output: v.x
> (2 rows)
>
> regression=# explain verbose select * from (values (1), (random())) v(x);
> QUERY PLAN
> -------------------------------------------------------------
> Values Scan on "*VALUES*" (cost=0.00..0.03 rows=2 width=8)
> Output: "*VALUES*".column1
> (2 rows)
>
> That's because the volatile function prevents subquery flattening.
>

Yes, that is by design. As I used is_simple_values() so if the values list
is not a simple one, which is not in this case, the alias won't be
reassigned.

> regards, tom lane
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-10-27 20:07:37 Re: Alias of VALUES RTE in explain plan
Previous Message Yasir 2024-10-27 19:57:41 Re: Alias of VALUES RTE in explain plan