Re: BUG #18885: ERROR: corrupt MVNDistinct entry - 2

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>
Cc: tharakan(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, PG Bug reporting form <noreply(at)postgresql(dot)org>
Subject: Re: BUG #18885: ERROR: corrupt MVNDistinct entry - 2
Date: 2025-04-14 14:41:22
Message-ID: c9225640-e2dc-4d9c-a598-0d1d1673b11f@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 4/12/25 00:30, Alexander Korotkov wrote:
> On Thu, Apr 10, 2025 at 3:28 PM Andrei Lepikhov <lepihov(at)gmail(dot)com> wrote:
>> ...
>> Here, I attempt to use this routine in the hash join bucket size
>> estimation. I transformed it a little, made it more general. Not sure it
>> is the best design, but it is debatable.
> ...
> SELECT FROM sb_1 LEFT JOIN sb_2 ON (sb_2.x=sb_1.x) AND (sb_1.x=sb_2.x)
> AND (sb_1.y=sb_2.y);
>
> When you use add_unique_group_var() which keeps varinfos unique then
> you can no longer expect that varinfos have the same order as
> origin_rinfos.
Ok, here is a patch that considers this issue. Now GroupVarInfo tracks
source RestrictInfo. Not sure it is an ideal approach, but we don't need
to synchronise the restrictions and corresponding varinfos.

On Fri, 11 Apr 2025 at 01:31, Tomas Vondra <tomas(at)vondra(dot)me> wrote:
> I think estimate_multivariate_bucketsize() needs to be more careful
> about building the GroupVarInfo list - in particular, it needs to do
> dance with examine_variable + add_unique_group_var + pull_var_clause,
> similar to estimate_num_groups() at line ~3532.
Yeah, estimate_num_groups and bucket size estimation have a lot in
common. It would be better to invent some common GroupVarInfo
preparation/estimation code for them, but specifics of HashJoin bucket
estimation need mcv_freq and result caching that limits intersection of
these estimators.

--
regards, Andrei Lepikhov

Attachment Content-Type Size
v0-0001-Be-more-conventional-in-estimating-hash-join-buck.patch text/x-patch 9.3 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Laurenz Albe 2025-04-14 17:30:42 Re: BUG #18894: values of JLC_COLLATE and LC_CTYPE in the database have changed from Japanese_Japan.932 to ja-jp
Previous Message Lele Gaifax 2025-04-14 09:55:51 Missing whitespace in pg_restore manpage