Re: Maintain the pathkesy for subquery from outer side information

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Maintain the pathkesy for subquery from outer side information
Date: 2021-07-25 08:16:06
Message-ID: CAKU4AWo6-=9mg3UQ5UJhGCMw6wyTPyPGgV5oh6dFvwEN=+hb_w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I think that in cases where there's not a semantic hazard involved,
> we'd usually have pulled up the subquery so that this is all moot
> anyway.
>

I get your point with this statement. Things driven by this idea look
practical and lucky. But for the UniqueKey stuff, we are not
that lucky.

SELECT pk FROM t; -- Maintain the UniqueKey would be not necessary.

However

SELECT DISTINCT pk FROM (SELECT volatile_f(a), pk from t) WHERE ..;

Maintaining the UniqueKey in subquery is necessary since it is useful outside.

--
Best Regards
Andy Fan (https://www.aliyun.com/)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2021-07-25 09:13:18 Re: Avoiding data loss with synchronous replication
Previous Message Andres Freund 2021-07-25 03:34:55 Re: pg14b1 stuck in lazy_scan_prune/heap_page_prune of pg_statistic