Re: [BUG?] estimate_hash_bucket_stats uses wrong ndistinct for avgfreq

Поиск
Список
Период
Сортировка
От Joel Jacobson
Тема Re: [BUG?] estimate_hash_bucket_stats uses wrong ndistinct for avgfreq
Дата
Msg-id 08da4388-d20b-4183-8ff6-5d83fa3fbb56@app.fastmail.com
обсуждение исходный текст
Ответ на Re: [BUG?] estimate_hash_bucket_stats uses wrong ndistinct for avgfreq  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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
Вложения

В списке pgsql-hackers по дате отправления: