On Tue, Jul 7, 2026 at 2:31 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> Attached is v2 addressing this. For a single grouping key, at most
> one NULL group remains, so we set it to 1 / (ndistinct + 1). With
> multiple grouping keys, the surviving NULL count is underdetermined,
> so we approximate it as zero; NULLs collapse far more aggressively
> than non-NULLs, so the real fraction is well below the base table's,
> and erring low keeps estimates on the hash-join-favoring side.
I've pushed the v2 patch.
- Richard