| From: | Enrique Sánchez <enriqueesanchz(at)gmail(dot)com> |
|---|---|
| To: | Chengpeng Yan <chengpeng_yan(at)outlook(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Extended statistics improvement: multi-column MCV missing values |
| Date: | 2026-07-28 23:38:53 |
| Message-ID: | CAOCkzA=ne7569=oYF9gT8WOaNL5NiZZ-w-wu-RbAtQ--bTmP1A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Chengpeng, thanks for the review!
On 26 Jul 2026 at 5:16, Chengpeng Yan (<chengpeng_yan(at)outlook(dot)com>) wrote:
> For patch 0001, apart from Ilia's comments, I only have one minor issue
> with a comment in `mcv_can_cap()`:
>
> Expressions are not supported, they can match multiple rows.
>
> is not quite accurate. Matching multiple rows is not specific to
> expressions; ordinary equality clauses may do so as well when they do
> not fully constrain all dimensions. Expressions are excluded here
> instead because the current full-coverage check only considers columns.
>
> Other than that, patch 0001 looks good to me.
I've addressed the comments in the attached v7 patch.
Regarding patch 0002, the formula seems reasonable as an estimate, but I
> am not convinced that it can serve as an upper bound. Some non-MCV
> combinations may be more frequent than the average, so using it as a cap
> does not seem justified. It may be more or less accurate than the
> existing per-column estimate depending on the data distribution.
Fair point, an average over the non-MCV combinations is not a true
upper bound, it's an estimation. I've been looking at how to reframe it
(it is essentially the same estimate var_eq_const() applies for single
columns on an MCV miss), but I think that discussion deserves its own
time (with a proper math analysis) and shouldn't hold back the rest.
So I'd propose we set 0002 aside for now and proceed with 0001, whose
reasoning is not affected by this: the least common MCV item is a
valid bound for any combination not in the list. I'll come back to
the ndistinct part in a follow-up.
Best regards,
Enrique.
| Attachment | Content-Type | Size |
|---|---|---|
| v7-0001-Cap-selectivity-when-values-are-not-in-multi-colu.patch | text/x-patch | 11.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bharath Rupireddy | 2026-07-29 01:53:00 | Re: Fix stale comment in parallel_vacuum_main(). |
| Previous Message | Enrique Sánchez | 2026-07-28 23:26:21 | Re: Extended statistics improvement: multi-column MCV missing values |