Re: BUG #19408: Bad plan for UNION ALL subquery with outer WHERE, ORDER BY, LIMIT, and separate indexes

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: link_xliv(at)hotmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19408: Bad plan for UNION ALL subquery with outer WHERE, ORDER BY, LIMIT, and separate indexes
Date: 2026-11-02 05:19:14
Message-ID: CAGRkXqRjd-t0HqsaJJdEcnwUDrrQNixJGyMn8mA-NsXvad3Gvw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> Another reason why this is only WIP quality is that it causes a bunch
> of plan changes in the regression tests. I haven't looked to see if
> they're all reasonable.

I went through them. Two defeat the test they are in. Most of the rest
turn Sort over Append into MergeAppend over per-child Sorts.

The report only goes wrong with a LIMIT, so the attached keeps just
the fractional part of your patch. One existing plan still changes.

I feel it is master only. Would you rather take this narrow version,
or the full one?

Thanks,
Shihao

Attachment Content-Type Size
nocfbot-v1-0001-Consider-sorting-the-cheapest-child-path-in-generate.patch application/octet-stream 7.6 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Guo 2026-11-02 05:51:25 Re: Wrong results: hashed SubPlan referenced twice after OR-qual extraction reuses a stale hash table (13 to 19beta4)
Previous Message Kirill Reshke 2026-11-02 02:40:37 Re: BUG #19817: CREATE UNIQUE INDEX on a partitioned table can silently attach an invalid, not-ready child index, le