Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Mingli Zhang <zmlpostgres(at)gmail(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs
Date: 2025-10-02 22:24:45
Message-ID: CAApHDvoKNCo+7SJCggvx2Ca+ribq2W+S29naPqrMxbR5wPWZBQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 3 Oct 2025 at 02:55, Mingli Zhang <zmlpostgres(at)gmail(dot)com> wrote:
> It seems that the optimization for `UNION ALL` is already implemented in the patch: it removes empty sub-paths and preserves the remaining ones.
> Should we add a test case to formally validate this behavior like Union cases?

If I were to do that, I'd have to come up with something that's
flatten_simple_union_all() proof. Maybe something like varying types
in the targetlist. I think it's probably not really worthwhile since
it's not testing any new code that is not already being tested by the
tests that I did add.

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-10-02 22:27:06 Re: Add stats_reset to pg_stat_all_tables|indexes and related views
Previous Message Nathan Bossart 2025-10-02 21:31:48 Re: disallow big-endian on aarch64