Re: a wrong index choose when statistics is out of date - Mailing list pgsql-hackers

From David Rowley
Subject Re: a wrong index choose when statistics is out of date
Date
Msg-id CAApHDvpHtoMGS+fGEuOzndTZ-_nMEgNmmPp3se3xn+nrDXYvSQ@mail.gmail.com
Whole thread Raw
In response to Re: a wrong index choose when statistics is out of date  (Andrei Lepikhov <a.lepikhov@postgrespro.ru>)
Responses Re: a wrong index choose when statistics is out of date
List pgsql-hackers
On Thu, 7 Mar 2024 at 21:17, Andrei Lepikhov <a.lepikhov@postgrespro.ru> wrote:
> I would like to ask David why the var_eq_const estimator doesn't have an
> option for estimation with a histogram. Having that would relieve a
> problem with skewed data. Detecting the situation with incoming const
> that is out of the covered area would allow us to fall back to ndistinct
> estimation or something else. At least, histogram usage can be
> restricted by the reltuples value and ratio between the total number of
> MCV values and the total number of distinct values in the table.

If you can think of a way how to calculate it, you should propose a patch.

IIRC, we try to make the histogram buckets evenly sized based on the
number of occurrences. I've not followed the code in default, I'd
guess that doing that allows us to just subtract off the MCV
frequencies and assume the remainder is evenly split over each
histogram bucket, so unless we had an n_distinct per histogram bucket,
or at the very least n_distinct_for_histogram_values, then how would
the calculation look for what we currently record?

David



pgsql-hackers by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: bug report: some issues about pg_15_stable(8fa4a1ac61189efffb8b851ee77e1bc87360c445)
Next
From: Andy Fan
Date:
Subject: Re: a wrong index choose when statistics is out of date