Re: explain analyze rows=%.0f

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>, Matheus Alcantara <matheusssilv97(at)gmail(dot)com>, Guillaume Lelarge <guillaume(at)lelarge(dot)info>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Ibrar Ahmed <ibrar(dot)ahmad(at)gmail(dot)com>, "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie>, vignesh C <vignesh21(at)gmail(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: explain analyze rows=%.0f
Date: 2025-02-12 08:54:33
Message-ID: eb73d4e1-4235-41b5-90a8-b0196550f62b@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/2/2025 03:46, Tom Lane wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Tue, Feb 11, 2025 at 12:14 PM Andrei Lepikhov <lepihov(at)gmail(dot)com> wrote:
>>> I support the idea in general, but I believe it should be expanded to
>>> cover all cases of parameterised plan nodes. Each rescan iteration may
>>> produce a different number of tuples, and rounding can obscure important
>>> data.
>
>> I agree strongly with all of this. I believe we should just implement
>> what was agreed here:
>> https://www.postgresql.org/message-id/21013.1243618236%40sss.pgh.pa.us
>> Let's just display 2 fractional digits when nloops>1, else 0, and call it good.
>
> Note that that formulation has nothing especially to do with
> parameterized plan nodes. Any nestloop inner side would end up
> getting shown with fractional rowcounts. Maybe that's fine.
I partly agree with this approach. Playing around a bit, I couldn't
invent a case where we have different numbers of tuples without
parameters. But I can imagine it is possible or may be possible in
future. So, it is not necessary to tangle fractional output with a
parameterised node.
I'm unsure about the inner subtree of a JOIN - subplan may refer to the
upper query and process a different number of tuples for every
evaluation without any JOIN operator.
May we agree on a more general formula to print at least two meaningful
digits if we have a fractional part?

Examples:
- actual rows = 2, nloops = 2 -> rows = 1
- actual rows = 9, nloops = 5 -> rows = 1.8
- actual rows = 101, nloops = 100 -> rows = 1.0
- actual rows = 99, nloops = 1000000 -> rows = 0.000099

It may guarantee that an EXPLAIN exposes most of the data passed the
node, enough to tangle it with actual timing and tuples at the upper
levels of the query.

>
> I suggest that when thinking about what to change here,
> you start by considering how you'd adjust the docs at
> https://www.postgresql.org/docs/devel/using-explain.html
> to explain the new behavior. If you can't explain it
> clearly for users, then maybe it's not such a great idea.
Agree

--
regards, Andrei Lepikhov

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shubham Khanna 2025-02-12 09:07:08 Re: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided.
Previous Message Bertrand Drouvot 2025-02-12 08:41:34 Re: Unneeded volatile qualifier in fmgr.c