| From: | Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com> |
|---|---|
| To: | Enrique Sánchez <enriqueesanchz(at)gmail(dot)com>, Chengpeng Yan <chengpeng_yan(at)outlook(dot)com> |
| Cc: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
| Subject: | Re: Extended statistics improvement: multi-column MCV missing values |
| Date: | 2026-06-09 12:39:09 |
| Message-ID: | 4f101ba3-1fcf-49e5-b4d8-28993bedba1f@tantorlabs.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 6/7/26 18:22, Enrique Sánchez wrote:
> ## v3-0001
> - logic remains the same
> - added a `IsA(clause, RestrictInfo)` check before casting to
> RestrictInfo in `mcv_can_cap()`
> - added some tests
1. mcv_can_cap() reimplements logic already present in
dependency_is_compatible_clause(). Shall we combine the two in order to
avoid code duplication?
2. mcv_can_cap() runs unconditionally before the if (is_or) branch, but
can_cap is only consumed in the else/AND branch. This means
mcv_can_cap() - including get_oprrest, syscache lookups per clause -
runs for every OR query as wasted work. Both can_cap and covered_attnums
should be moved inside the else branch.
>
> ## v3-0002
> - used ndistinct to calculate `non_mcv_sel = (1.0 - mcv_totalsel) /
> (ndistinct - mcv_nitems)` and applied it as an upper bound for non-MCV
> combinations, similarly to what `var_eq_const()` does in `selfuncs.c`
get_ndistinct_for_keys() reimplements the ndistinct item lookup already
present in estimate_multivariate_ndistinct(). Both functions iterate
over MVNDistinct->items match by attributes count.
--
Best regards,
Ilia Evdokimov,
Tantor Labs LLC,
https://tantorlabs.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-06-09 13:16:32 | Re: [PATCH v4] pg_stat_statements: Add last_execution_start column |
| Previous Message | Nitin Jadhav | 2026-06-09 12:38:36 | Re: [PATCH] Fix minRecoveryPoint not advanced past checkpoint in CreateRestartPoint |