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 1tkkdb-006URk-Th for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Feb 2025 14:01:19 +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 1tkkdZ-008olI-Jc for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Feb 2025 14:01:17 +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 1tkkdZ-008ol6-7r for pgsql-hackers@lists.postgresql.org; Wed, 19 Feb 2025 14:01:17 +0000 Received: from forward500b.mail.yandex.net ([178.154.239.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tkkdW-001lqb-2q for pgsql-hackers@lists.postgresql.org; Wed, 19 Feb 2025 14:01:17 +0000 Received: from mail-nwsmtp-smtp-production-main-87.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-87.sas.yp-c.yandex.net [IPv6:2a02:6b8:c23:46ca:0:640:84a:0]) by forward500b.mail.yandex.net (Yandex) with ESMTPS id 784F461877; Wed, 19 Feb 2025 17:01:13 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-87.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 61Xp440OrW20-m8VKbqVr; Wed, 19 Feb 2025 17:01:12 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tantorlabs.com; s=mail; t=1739973672; bh=72xd2lM3NM+gf1va9G0JDR277zqo1WGTe+MKpF8XvmA=; h=From:In-Reply-To:Cc:Date:References:To:Subject:Message-ID; b=TKHGJJHjMi28HmEpD0E/M0GwvEg6XxhbDPA73evt4ae3JFFKtsa5cCH5wHgQAf7Kx UTrnr/LdKjAOAqxuv2Wm/bPsgsrAz1jRxs2Lk1inSFx3ruMd9C0WLa9MfbbnlpRGCR bSzIucHS3eN+uHwT6+UyaND1eu7/PlstdjU5PmW0= Authentication-Results: mail-nwsmtp-smtp-production-main-87.sas.yp-c.yandex.net; dkim=pass header.i=@tantorlabs.com Message-ID: <7ab512ac-eed1-4fc8-9c5f-b42c0b0d313e@tantorlabs.com> Date: Wed, 19 Feb 2025 17:01:06 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: explain analyze rows=%.0f To: Andrei Lepikhov , Robert Haas Cc: pgsql-hackers@lists.postgresql.org, Tom Lane , Matheus Alcantara , Guillaume Lelarge , Daniel Gustafsson , Ibrar Ahmed , "Gregory Stark (as CFM)" , Amit Kapila , Justin Pryzby , Peter Geoghegan , vignesh C , "David G. Johnston" , Alena Rybakina References: <70bc1af0-6910-4f71-84ba-fa02095fe9ba@tantorlabs.com> <3212947.1739306803@sss.pgh.pa.us> <3365160.1739385615@sss.pgh.pa.us> <0e4c813a-18eb-41e2-8edb-89b78d43c82d@gmail.com> <01ec86c1-e04b-4cbe-b641-22cae8b87604@tantorlabs.com> <73e2440e-7d8b-4860-974d-931a93326d95@gmail.com> Content-Language: en-US From: Ilia Evdokimov In-Reply-To: <73e2440e-7d8b-4860-974d-931a93326d95@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 18.02.2025 23:55, Andrei Lepikhov wrote: > On 17/2/2025 15:19, Robert Haas wrote: >> On Mon, Feb 17, 2025 at 3:08 AM Ilia Evdokimov >> if (nloops > 1) >> >> Instead of: >> >> if (nloops > 1 && rows_is_fractonal) >> >> I don't think it's really safe to just cast a double back to int64. In >> practice, the number of tuples should never be large enough to >> overflow int64, but if it did, this result would be nonsense. Also, if >> the double ever lost precision, the result would be nonsense. If we >> want to have an exact count of tuples, we ought to change ntuples and >> ntuples2 to be uint64. But I don't think we should do that in this >> patch, because that adds a whole bunch of new problems to worry about >> and might cause us to get nothing committed. Instead, I think we >> should just always show two decimal digits if there's more than one >> loop. >> >> That's simpler than what the patch currently does and avoids this >> problem. Perhaps it's objectionable for some other reason, but if so, >> can somebody please spell out what that reason is so we can talk about >> it? > I can understand two decimal places. You might be concerned about > potential issues with some codes that parse PostgreSQL explains. > However, I believe it would be beneficial to display fractional parts > only when iterations yield different numbers of tuples. Given that I > often work with enormous explains, I think this approach would enhance > the readability and comprehension of the output. Frequently, I may see > only part of the EXPLAIN on the screen. A floating-point row number > format may immediately give an idea about parameterisation (or another > reason for the subtree's variability) and trace it down to the source. > The idea of indicating to the user that different iterations produced varying numbers of rows is quite reasonable. Most likely, this would require adding a new boolean field to the Instrumentation structure, which would track this information by comparing the rows value from the current and previous iterations. However, there is a major issue: this case would be quite difficult to document clearly. Even with an example and explanatory text, users may still be confused about why rows=100 means the same number of rows on all iterations, while rows=100.00 indicates variation. Even if we describe this in the documentation, a user seeing rows=100.00 will most likely assume it represents an average of 100 rows per iteration and may still not realize that the actual number of rows varied. If we want to convey this information more clearly, we should consider a more explicit approach. For example, instead of using a fractional value, we could display the minimum and maximum row counts observed during execution (e.g.,rows=10..20, formatting details could be discussed). However, in my opinion, this discussion is beyond the scope of this thread. Any thoughts? -- Best regards, Ilia Evdokimov, Tantor Labs LLC.