| From: | zengxx <xiangxin_zeng(at)qq(dot)com> |
|---|---|
| To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PATCH 0/2] Improve ndistinct estimates for flattened UNION ALL |
| Date: | 2026-10-16 00:37:10 |
| Message-ID: | tencent_AF4D43955D36DFCFCF34FE117DAC0ABEB008@qq.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Oct 16, 2026 05:36, David Rowley <dgrowleyml(at)gmail(dot)com> wrote
>> overstate Memoize hit rates.
>
> If that's true for Memoize, please provide a test case that shows a
> Memoize node being used on a DEFAULT_NUM_DISTINCT estimate.
Thanks for pointing this out. You are right.
I do not have a test case showing a Memoize node being used on a
DEFAULT_NUM_DISTINCT estimate. In fact, for Memoize I am trying to
address the opposite problem: when a join contains a UNION ALL
subquery, the planner detects DEFAULT_NUM_DISTINCT and avoids using
Memoize. This patch tries to widen that boundary. I still use the hi
estimate (the sum of all member estimates, when available) to avoid
overstating the hit rate.
Below are the cases I have tested where Memoize is used more
effectively. I have not yet found a counterexample in which Memoize
caused a worse plan.
Thanks.
| Attachment | Content-Type | Size |
|---|---|---|
| postgresql-flattened-union-all-memoize-reproducer.sql | application/octet-stream | 3.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-10-16 00:38:52 | Re: [PG19] psql backslash commands fail with translated messages and a non UTF-8 client encoding |
| Previous Message | Manu | 2026-10-16 00:26:07 | Re: UNDO with FILEOPS, and the FLUX table AM |