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 1tzJ3P-000a1B-1T for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 17:36:07 +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 1tzJ3N-009Rje-FO for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 17:36:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tzJ3N-009RjW-5i for pgsql-hackers@lists.postgresql.org; Mon, 31 Mar 2025 17:36:05 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tzJ3K-002Gmt-23 for pgsql-hackers@lists.postgresql.org; Mon, 31 Mar 2025 17:36:04 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-ac28e66c0e1so700802666b.0 for ; Mon, 31 Mar 2025 10:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743442561; x=1744047361; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oYcoR4EbfOgUYRhEl64XE73iLZBztNne/d8BEJOc294=; b=lcOdECxsEa7/e4Jg1RiCSxba2Omste61RDA/1yTntv/CUW6310dY6MdiwJlnLKDKh1 RmzpAYE09dPnR1/vm9qxEZ/fe1NXFEU3/qFmS62UCPZTaaFFgGRG0ag6hvnrVG5Jqg4Z PRB5Y1ea1BNgg+Eyw9vhe202munKzPzmZyZl1c17WMDZFIMQ8trPY9Nlqu+FibJHj1CQ 4LXMCH1SQBdFwUyQTT4zWJS4PCM/2+oASssreqfEvHZMBivj+t1Pk9X1Ekhc8wkyoyzN rmxk737/akLVmDStyy+mmIgwZ7D9sYpXDyJLcOZehKS9cysuQMJ4HrOxHT5bp9ZDEv3K TW4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743442561; x=1744047361; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oYcoR4EbfOgUYRhEl64XE73iLZBztNne/d8BEJOc294=; b=doiLpN72PMyBXlYxBQHOHX7QhKST9A57QzT4Ou0exIRuxeufdhV7OMnGzfcdxlA2yI IMtGwiJJQo1T2Fw7dLavAtUH7tq00/xQJWarVGz1F2+1/EuBKMG+XY8SnmluJwTzAom1 SIkC0EHQNDoIgJBSEp2wqes6LFiwRyYdcaHbLYlJucJunVubO41OCQs8RVV0fCNdMvGG VkUOwWW4+7TLHPrL17y5etx6CTtXbZMaqzZh2Zb+AxSyje6jaN6pd7ZqTu66crYz8eSS a3Df2cSoa6ztGarZdBW0TfJVaqzsxwt2Qk6qxyJyLAKR7VgfwGobGgdbgLLP0h7e40RW kLKg== X-Forwarded-Encrypted: i=1; AJvYcCVA6t4OqyveC5Gb5pttCkTA4Q2Beps9vbx28eMo5iTPnA3qWPb3lHSH1VpCHx9hFsk6Po7XE4hQdmSSKMFz@lists.postgresql.org X-Gm-Message-State: AOJu0YwydOQUUwh8L91zYDaUg4ofnOb7g7cth/tJF34RJb/ij9LoeA3+ 3+kBMFVYZtxKvmuIyUcYKQ218rtJRiHCwAd5FkLwgr55EHpgL7pDZLotUPmwb6fCxmNnMX6fmO/ V1Ii1lzLyDqgHLKUat5vqy2VP4j8= X-Gm-Gg: ASbGncvC9Uklcem/itOjSILCVY1BOZ0eTVElzAhLXnbSvxIwfrlE1u1wd/m5R62x3sE Pf7zvx139mwIzR5UPxexLHwokaFlEpnULsgxav7TjZ2L3y/ovZdA8izzEQOTfDgs8jOuauHwUNi G5dOo0jfIax0AEwcmVcJAsIMBfBQ== X-Google-Smtp-Source: AGHT+IFxJ3GrdfLePV2lnfgfCtHUzzU6BfrdlKBR7j6aFB2Rcw2HtzxfbICqDo0G/AuwV6vYDDcnCeH7gU8aJz8tKhA= X-Received: by 2002:a17:907:c1b:b0:ac3:48e4:f8bb with SMTP id a640c23a62f3a-ac738be3d13mr850439966b.41.1743442561214; Mon, 31 Mar 2025 10:36:01 -0700 (PDT) MIME-Version: 1.0 References: <3737950.1740182671@sss.pgh.pa.us> <3816053.1740190267@sss.pgh.pa.us> <40663fc5-edac-4b45-a2aa-a76976700ed9@tantorlabs.com> <432c75b0-be5f-4836-b46b-98c505eaad28@postgrespro.ru> In-Reply-To: From: Robert Haas Date: Mon, 31 Mar 2025 13:35:49 -0400 X-Gm-Features: AQ5f1JoGMIL2Kd_LE5c9zN1oqVX_Y7WRKdUpBLQh7qhvR5Zq6BMFdbnTG7dBjbE Message-ID: Subject: Re: explain analyze rows=%.0f To: Ilia Evdokimov Cc: Matthias van de Meent , Tom Lane , Andrei Lepikhov , pgsql-hackers@lists.postgresql.org, Guillaume Lelarge , Matheus Alcantara , Alena Rybakina Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 11, 2025 at 5:58=E2=80=AFAM Ilia Evdokimov wrote: > In the stats_ext regression test, there is a function > check_estimated_rows that returns actual rows as an integer. Currently, > none of the test cases produce a non-zero fractional part in actual rows. > > The question is: should this function be modified to return a fractional > number instead of an integer? > > Personally, I don=E2=80=99t see much value in doing so, because the purpo= se of > the test is to compare the estimated row count with the actual number of > rows. It is also unlikely that there will be test cases where loops > 1, > and the presence of a fractional part does not change the essence of the > test. > > What do you think? I suppose the way this is currently coded, it will have the effect of extracting the integer part of the row estimate. That doesn't really seem like a bad idea to me, so I'm not sure it's worth trying to adjust anything here. One thing that I just noticed, though, is that we added two decimal places to the actual row count, but not the estimated row count. So now we get stuff like this: -> Seq Scan on pgbench_branches b (cost=3D0.00..1.10 rows=3D10 width=3D364) (actual time=3D0.007..0.009 rows=3D10.00 loops=3D1) But why isn't it just as valuable to have two decimal places for the estimate? I theorize that the cases that are really a problem here are those where the row count estimate is between 0 and 1 per row, and rounding to an integer loses all precision. --=20 Robert Haas EDB: http://www.enterprisedb.com