Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tzMFj-001CFV-LI for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 21:01:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tzMEk-00CLqw-Az for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 21:00:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tzMEj-00CLqj-Qp for pgsql-hackers@lists.postgresql.org; Mon, 31 Mar 2025 21:00:01 +0000 Received: from forward502d.mail.yandex.net ([178.154.239.210]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tzMEf-002D4S-2j for pgsql-hackers@lists.postgresql.org; Mon, 31 Mar 2025 21:00:00 +0000 Received: from mail-nwsmtp-smtp-production-main-94.klg.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-94.klg.yp-c.yandex.net [IPv6:2a02:6b8:c42:e2ca:0:640:d17d:0]) by forward502d.mail.yandex.net (Yandex) with ESMTPS id 3B84060ABB; Mon, 31 Mar 2025 23:59:53 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-94.klg.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id nxcBiYCLfiE0-UqrfI9nE; Mon, 31 Mar 2025 23:59:52 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tantorlabs.com; s=mail; t=1743454792; bh=jUAbggaYhhT3zmUwqzQjYVtmHmXvqw8CIWtYT++E/GE=; h=In-Reply-To:Cc:Date:References:To:Subject:Message-ID:From; b=OmmXPNlmI2UGOXOEQqmmids6QqcR5lFqjEtsGbXXzSoqE9dI14/eVJrM3O1CP9SKG 5GWcDQmF90/Wyd5EQvvcmGJ311ca1ycg7s1zQiW5t+LnoOYcN+Kyfl+v8OXrKCX2hp gyFPqAZ5qWPkekP/C98JzgeeRb/Ha3lWh5tTSOro= Authentication-Results: mail-nwsmtp-smtp-production-main-94.klg.yp-c.yandex.net; dkim=pass header.i=@tantorlabs.com Content-Type: multipart/alternative; boundary="------------Nbi5DO85ryvDFRlI7R76ZvjY" Message-ID: <1a7b5bea-336b-40b5-a7c8-c7aefe8778b6@tantorlabs.com> Date: Mon, 31 Mar 2025 23:59:48 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: explain analyze rows=%.0f To: Robert Haas , Tom Lane Cc: Matthias van de Meent , Andrei Lepikhov , pgsql-hackers@lists.postgresql.org, Guillaume Lelarge , Matheus Alcantara , Alena Rybakina References: <3816053.1740190267@sss.pgh.pa.us> <40663fc5-edac-4b45-a2aa-a76976700ed9@tantorlabs.com> <432c75b0-be5f-4836-b46b-98c505eaad28@postgrespro.ru> <4118244.1743443395@sss.pgh.pa.us> Content-Language: en-US From: Ilia Evdokimov In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------Nbi5DO85ryvDFRlI7R76ZvjY Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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. --------------Nbi5DO85ryvDFRlI7R76ZvjY Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


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.

--------------Nbi5DO85ryvDFRlI7R76ZvjY--