Re: BUG #18885: ERROR: corrupt MVNDistinct entry - 2
Tomas Vondra <tomas@vondra.me>
From: Tomas Vondra <tomas@vondra.me>
To: tharakan@gmail.com, pgsql-bugs@lists.postgresql.org,
PG Bug reporting form <noreply@postgresql.org>
Cc: Alexander Korotkov <aekorotkov@gmail.com>
Date: 2025-04-09T22:47:43Z
Lists: pgsql-bugs
On 4/9/25 15:46, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 18885
> Logged by: Robins Tharakan
> Email address: tharakan@gmail.com
> PostgreSQL version: Unsupported/Unknown
> Operating system: Ubuntu
> Description:
>
> The following SQL triggers "ERROR: corrupt MVNDistinct entry", however this
> seems to be unrelated to a recent bugfix[1] for a similar issue (thus '2' in
> the $SUBJECT).
>
> The surfacing commit appears to be 6bb6a62f3cc45624c601d5270673a17447734629
> [2].
>
Thanks for the report. I only looked at this very briefly, but I agree
this seems to be a bug in 6bb6a62f3cc45624c601d5270673a17447734629,
because it simply ignores the possibility that multiple join clauses
could share the same Var. Which is the case in the reproducer, where the
join clause is simply
... ON (e.d=f.d) AND (e.d=f.d);
Which then leads to confusion when matching the MVDistinct entries.
I think estimate_multivariate_bucketsize() needs to be more careful
about building the GroupVarInfo list - in particular, it needs to do the
dance with examine_variable + add_unique_group_var + pull_var_clause,
similar to estimate_num_groups() at line ~3532.
regards
--
Tomas Vondra
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Properly prepare varinfos in estimate_multivariate_bucketsize()
- 9f404d7922e8 18.0 landed
-
Improve comments for estimate_multivariate_ndistinct()
- f3281f9f9395 18.0 landed
-
Use extended stats for precise estimation of bucket size in hash join
- 6bb6a62f3cc4 18.0 cited
-
Ignore nullingrels when looking up statistics
- e28033fe1af8 18.0 cited