Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9OXC-0001xv-8t for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jul 2022 10:14:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o9OXA-0002Pc-Qy for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jul 2022 10:14:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9OX9-0002Do-Tm for pgsql-hackers@lists.postgresql.org; Thu, 07 Jul 2022 10:14:56 +0000 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o9OX3-0003JZ-9l for pgsql-hackers@postgresql.org; Thu, 07 Jul 2022 10:14:54 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-10bf634bc50so15643957fac.3 for ; Thu, 07 Jul 2022 03:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=VcNR/PoEBq4MI+kpVjvP8QFw2mAba6uqQo+edanzGpI=; b=kiIwsZaKcgCA7zXnsVWMAs0Lj6fx8EOi/5tC5pHv4M84uH+mA6Ruzwp5Z6px2ayQRk uarM92tq5DpQAH1r3BvRdQf9Kw6gssYmJGX1pSYud8lPshqPwhHEXZf9K8t+4uM8PGx/ k8xw2sEfjM3Ron0woKa+t5vzXoUJLfArF42StFgpniryAuPZOkHML/JqJKqpy1WNIPO+ 6WziussPGjQKsZJoUp5s3Tw3DmhLivEMXfopUuYZPpSb8EYIcni8D4/0GhBUR8gLY+bl Rksep2xCZScIDHMpTPBreeJIuMtT4vIX2vQB9InioF047WAc6/OcWoOzUecqxhK5nB6o 90qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=VcNR/PoEBq4MI+kpVjvP8QFw2mAba6uqQo+edanzGpI=; b=Hy1SloWz5it15ZZetPy+jNMmKVONDEOqzFplL/Ivj02gWndePEjZzuBxs/KpajDr0K WYeoQC2h4wi+YiBJIoOkcP/r4VeuOOB2wvJ/Ydc52GdKFO7vrwkYYAymT9PN773R0wck iNz3xrtoLLWzCTwvDJ66JEMiAqVv7pgPF3NPa6LrIl5zAs0L/pocK6yMy1jpg2ZQRQ77 bpNPJWOR0XMfXQ2XMBZJ6FuMDC2mG252ioQSLVT5JRlnAM1wBEpWX9y4xMBKMbJU9iuq np8KqRYU8J4/xQRKlQUmLm/g8ICgU1sIm7TVMm6J9ZRMwHWvIbCVQ3+VkDV6IpStEDEu MrIQ== X-Gm-Message-State: AJIora+WcULeceBl5gcJiLkfcjPy3tOHbVUcTmznvxeACwTZL6jgeXKt Vb6IbIFugAOiAy4H6fszsc2nypOW6NpslaKmTmM= X-Google-Smtp-Source: AGRyM1vALTweVZCML5t61EGSDl0r9FOArWDdsHlTYUEZnM7+k3WBeihVfsNGjVG0+fDZXVMTLBcKXf+POiBdS7aCpBI= X-Received: by 2002:a05:6870:4603:b0:101:72f6:ba77 with SMTP id z3-20020a056870460300b0010172f6ba77mr2298210oao.38.1657188888377; Thu, 07 Jul 2022 03:14:48 -0700 (PDT) MIME-Version: 1.0 References: <603c8f070905281830g2e5419c4xad2946d149e21f9d@mail.gmail.com> <4A1F4FD5.7060204@timbira.com> <4A249CE9.6050708@cheapcomplexdevices.com> <1243950060.23910.58.camel@ebony.2ndQuadrant> <11926.1243953507@sss.pgh.pa.us> In-Reply-To: From: vignesh C Date: Thu, 7 Jul 2022 15:44:37 +0530 Message-ID: Subject: Re: explain analyze rows=%.0f To: Ibrar Ahmed Cc: "David G. Johnston" , "pgsql-hackers@postgresql.org" , Robert Haas , Simon Riggs , Ron Mayer , Euler Taveira de Oliveira , Tom Lane 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 Thu, Jun 23, 2022 at 2:25 AM Ibrar Ahmed wrote: > > > > On Thu, Jun 23, 2022 at 1:04 AM David G. Johnston wrote: >> >> On Wed, Jun 22, 2022 at 12:11 PM Ibrar Ahmed wro= te: >>> >>> On Thu, Jun 23, 2022 at 12:01 AM Tom Lane wrote: >>>> >>>> Robert Haas writes: >>>> > On Jun 2, 2009, at 9:41 AM, Simon Riggs wrot= e: >>>> >> You're right that the number of significant digits already exceeds = the >>>> >> true accuracy of the computation. I think what Robert wants to see = is >>>> >> the exact value used in the calc, so the estimates can be checked m= ore >>>> >> thoroughly than is currently possible. >>>> >>>> > Bingo. >>>> >>>> Uh, the planner's estimate *is* an integer. What was under discussion >>>> (I thought) was showing some fractional digits in the case where EXPLA= IN >>>> ANALYZE is outputting a measured row count that is an average over >>>> multiple loops, and therefore isn't necessarily an integer. In that >>>> case the measured value can be considered arbitrarily precise --- thou= gh >>>> I think in practice one or two fractional digits would be plenty. >>>> >>>> regards, tom lane >>>> >>>> >>> Hi, >>> I was looking at the TODO list and found that the issue requires >>> a quick fix. Attached is a patch which shows output like this. >> >> >> Quick code review: >> >> + "actual rows=3D%.0f loops=3D%.0f": " rows=3D%.2f loops=3D%.0f", >> >> The leading space before the else block "rows" does not belong. >> >> There should be a space after the colon. >> > Thanks, David for your quick response. I have updated the patch. > >> >> The word "actual" that you are dropping in the else block seems like it = should belong - it is a header for the entire section not just a modifier f= or the word "rows". This is evidenced by the timing block verbiage where r= ows is standalone and the word actual comes before time. In short, only th= e format specifier should change under the current scheme. Both sections. >> >> - WRITE_FLOAT_FIELD(rows, "%.0f"); >> + WRITE_FLOAT_FIELD(rows, "%.2f"); >> >> This one looks suspicious, though I haven't dug into the code to see exa= ctly what all is being touched. That it doesn't have an nloops condition l= ike everything else stands out. >> > I was also thinking about that, but I don't see any harm when we ultimate= ly truncating that decimal > at a latter stage of code in case of loop =3D 1. Thanks for the patch. 1) There are some existing regression tests that are failing, you should update the expect files accordingly for the same: --- /home/vignesh/postgres/src/test/regress/expected/select_parallel.out 2022-05-18 20:51:46.874818044 +0530 +++ /home/vignesh/postgres/src/test/regress/results/select_parallel.out 2022-07-07 15:27:34.450440922 +0530 @@ -545,17 +545,17 @@ explain (analyze, timing off, summary off, costs off) select count(*) from tenk1, tenk2 where tenk1.hundred > 1 and tenk2.thousand=3D0; - QUERY PLAN --------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------= --- Aggregate (actual rows=3D1 loops=3D1) -> Nested Loop (actual rows=3D98000 loops=3D1) -> Seq Scan on tenk2 (actual rows=3D10 loops=3D1) Filter: (thousand =3D 0) Rows Removed by Filter: 9990 - -> Gather (actual rows=3D9800 loops=3D10) + -> Gather (actual rows=3D9800.00 loops=3D10) Workers Planned: 4 Workers Launched: 4 - -> Parallel Seq Scan on tenk1 (actual rows=3D1960 loops=3D= 50) + -> Parallel Seq Scan on tenk1 (actual rows=3D1960.00 loops= =3D50) Filter: (hundred > 1) test select_parallel ... FAILED 744 ms partition_prune ... FAILED 861 ms explain ... FAILED 134 ms memoize ... FAILED 250 ms 2) This change is not required as part of this patch: --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -122,7 +122,7 @@ bool bsysscan =3D false; * lookups as fast as possible. */ static FullTransactionId XactTopFullTransactionId =3D {InvalidTransactionI= d}; -static int nParallelCurrentXids =3D 0; +static int nParallelCurrentXids =3D 0; static TransactionId *ParallelCurrentXids; Regards, Vignesh