From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | "sunw(dot)fnst" <936739278(at)qq(dot)com> |
Cc: | pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: The issue of incorrect width estimation in UNION queries |
Date: | 2025-09-29 01:50:19 |
Message-ID: | CAApHDvokhrCXE0w5zCKNUYvyCQABE0+bB7OTmfXPo_F=aRXLPQ@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Fri, 26 Sept 2025 at 09:42, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> Here's an updated patch which includes adjusting the width estimate
> for generate_nonunion_paths() too.
>
> I gave a bit of thought to how that should work for EXCEPT and
> INTERSECT and concluded that for EXCEPT, we should take the width
> estimate for the left-hand child, as no rows from the right-child will
> be used. For INTERSECT, I couldn't think of anything better than
> taking the weighted average of both children, the same as UNION. Of
> course, only the rows which exist in both will make the final result,
> but I don't see any way to do anything smart with a single width
> estimate for each child.
I looked at this again today. All seems fairly trivial and not too
dissimilar to what happens in set_append_rel_size(). I did consider if
it should be done by having some special varno for setops and then
have get_expr_width() to something better, but I don't see how that
would work exactly. In any case, that would be way more complex than
what I did.
With some more adjustments to the comments, I pushed the v1 patch.
David
From | Date | Subject | |
---|---|---|---|
Next Message | LEMAIRE Leslie - SG/DNUM/UNI/DRC (Chargée de mission) | 2025-09-29 12:36:15 | Cast to regrole on a literal string in a PL/pgSQL function |
Previous Message | Thomas Munro | 2025-09-28 23:47:52 | Re: BUG #19062: PostgreSQL 12.22 does not compile because of conflicting types for CollationCreate |