On Sun, Mar 1, 2026, at 22:12, Tom Lane wrote: > What is more sensible I think is just to clamp estfract to be at least > mcv_freq always, dispensing with a whole bunch of the complication > here. We actually don't need avgfreq at all, and therefore not > stanullfrac, and also the ad-hoc range clamp at the bottom no longer > seems necessary. Interestingly, this also makes the logic more > nearly like the "isdefault" early exit: > > *bucketsize_frac = (Selectivity) Max(0.1, *mcv_freq); > > which IIRC was added a lot later than the original logic.
Nice simplification. > So I end with the attached draft patch. Very interestingly, > neither this version nor your lets-calculate-avgfreq-later > patch change any regression tests at all compared to git HEAD. LGTM. > Maybe we should try to add a case that does change. Yes, I think that would be good. Attached patch adds a new test that does change. /Joel
estimate_hash_bucket_stats-test.patch
Description: Binary data
