Re: Optimize cardinality estimation when unique keys are fully covered

From: Nico Williams <nico(at)cryptonector(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: feichanghong <feichanghong(at)qq(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Optimize cardinality estimation when unique keys are fully covered
Date: 2025-11-21 19:52:01
Message-ID: aSDC4ex5V4YbUxY/@ubby
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 21, 2025 at 01:52:07PM -0500, Tom Lane wrote:
> But the conclusion that "where t1.a = t2.a and t1.b = 0" means that
> t1's rowcount is 1 only applies if the join is implemented as an inner
> indexscan. If we choose some other method, say a hash join based on
> a seqscan of t1, having forced that rowcount to 1 would produce
> completely false estimates.

But wouldn't knowing that for an inner indexscan the cardinality is one
then drive the optimizer to choose inner indexscan over other methods?

Nico
--

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Burd 2025-11-21 19:52:03 Re: [PATCH] Fix ARM64/MSVC atomic memory ordering issues on Win11 by adding explicit DMB ​barriers
Previous Message Jacob Champion 2025-11-21 19:42:41 Re: RFC 9266: Channel Bindings for TLS 1.3 support