Re: [PATCH 0/2] Improve ndistinct estimates for flattened UNION ALL

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: zengxx <xiangxin_zeng(at)qq(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-15 21:36:41
Message-ID: CAApHDvqjEiQ9h9DwTnwtm30cUk9Ad7R3C3vLCZj+dOTTz-UB-Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 16 Oct 2026 at 05:20, zengxx <xiangxin_zeng(at)qq(dot)com> wrote:
> return DEFAULT_NUM_DISTINCT. A union containing millions of keys
> therefore looks like a 200-distinct-value domain. That can make a
> semi-join estimate that nearly every outer row matches, undercount
> GROUP BY/DISTINCT output groups, or 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. There's
specific coding in cost_memoize_rescan() which is meant to stop that
from happening.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-10-15 21:38:11 Re: Reject COPY TO of unlogged relations during recovery
Previous Message Zsolt Parragi 2026-10-15 21:25:37 Re: PoC: Simplify recovery after dropping a table by LOGGING the restore LSN