Re: Improve UNION's output rowcount estimate

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Chengpeng Yan <chengpeng_yan@outlook.com>
Cc: David Rowley <dgrowleyml@gmail.com>, Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-07-01T06:34:18Z
Lists: pgsql-hackers
On Thu, Jun 25, 2026 at 12:12 PM Chengpeng Yan
<chengpeng_yan@outlook.com> wrote:
> The added regression test looks reasonable to me, since it checks the
> plan change that motivated the patch. One small question: would it be
> worth adding a direct row-estimate check, perhaps with a helper like
> planner_est.sql’s explain_mask_costs() so that rows= stays visible while
> cost/width are masked? The existing plan-shape test may already be
> sufficient, though.

I think the plan-shape test is sufficient here.  I've committed this
patch to master.  Thanks for all the reviews.

- Richard



Commits

  1. Improve UNION's output row count estimate