Re: explain analyze rows=%.0f
Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
From: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
To: Robert Haas <robertmhaas@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Matthias van de Meent <boekewurm+postgres@gmail.com>,
Andrei Lepikhov <lepihov@gmail.com>, pgsql-hackers@lists.postgresql.org,
Guillaume Lelarge <guillaume@lelarge.info>,
Matheus Alcantara <matheusssilv97@gmail.com>,
Alena Rybakina <a.rybakina@postgrespro.ru>
Date: 2025-03-31T20:59:48Z
Lists: pgsql-hackers
On 31.03.2025 22:09, Robert Haas wrote: > Oh, right. I've never really understood why we round off to integers, > but the fact that we don't allow row counts < 1 feels like something > pretty important. My intuition is that it probably helps a lot more > than it hurts, too. We definitely shouldn’t remove the row counts < 1 check, since there are many places in the planner where we divide by rows. This mechanism was added specifically to prevent division by zero. Also, allowing rows estimates below 1 can sometimes make the planner overly optimistic, leading it to prefer cheaper-looking plans that may not perform well in practice. For example, choosing a Nested Loop instead of a more appropriate Hash Join. Allowing fractional rows > 1 might help improve planner accuracy in some cases, but this needs further study to fully understand the impact. -- Best regards, Ilia Evdokimov, Tantor Labs LLC.