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

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs
Date: 2025-10-02 12:09:27
Message-ID: CAApHDvpk88w3MrzgZShROjQw3NPK54YKr_hOi0++0QKGwTq+-g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 2 Oct 2025 at 16:21, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I'm wondering if it could be shortened a great deal by
> handling left-input-dummy and EXCEPT-ALL-with-right-input-dummy
> but leaving the EXCEPT-with-right-input-dummy case unimproved.

Good idea. Less code and still get to keep the one that did well in
the benchmark. See attached.

I ended up splitting the patch in two. 0001 for UNION only, then 0002
for the INTERSECT and EXCEPT.

David

Attachment Content-Type Size
v2-0001-Teach-UNION-planner-to-remove-dummy-inputs.patch application/octet-stream 6.9 KB
v2-0002-Teach-planner-to-short-circuit-EXCEPT-INTERSECT-w.patch application/octet-stream 7.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Burd 2025-10-02 12:09:55 Re: [PATCH] Add tests for Bitmapset
Previous Message Arseniy Mukhin 2025-10-02 12:06:38 Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue