Re: [BUG?] estimate_hash_bucket_stats uses wrong ndistinct for avgfreq
Joel Jacobson <joel@compiler.org>
From: "Joel Jacobson" <joel@compiler.org>
To: "Tender Wang" <tndrwang@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>,
"Tom Lane" <tgl@sss.pgh.pa.us>
Date: 2026-02-27T15:54:10Z
Lists: pgsql-hackers
On Thu, Feb 26, 2026, at 14:56, Tender Wang wrote: > I think your analysis is correct. > After bd3e3e9, the mcv_freq is calculated by RelOptInfo.rows, which > accounts for restriction clauses. > But avgfreq is for the raw relation. ... > So I agree with your fix. > I added Tom to the cc list. He may know more about this. Many thanks for testing and reviewing. Here is the commitfest entry, if you want to register as Reviewer and/or think it's Ready for Committer: https://commitfest.postgresql.org/patch/6528/ /Joel
Commits
-
Fix estimate_hash_bucket_stats's correction for skewed data.
- e6a1d8f5acbc 19 (unreleased) landed
-
Correctly calculate "MCV frequency" for a unique column.
- d80b0225010f 19 (unreleased) landed