Show 'Rows Removed by Filter' with two fractional digits in EXPLAIN

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
Subject: Show 'Rows Removed by Filter' with two fractional digits in EXPLAIN
Date: 2026-11-06 08:57:16
Message-ID: f763b98b-b4ed-474f-96fd-391459546622@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Since ddb17e387aa, EXPLAIN reports per-loop actual rows with two decimal digits.
The neighbouring counters - Rows Removed by Filter, by Join Filter - are divided
by nloops too, but are still printed with zero digits. In a parameterised inner
side this makes the two numbers contradict each other, for example:

-> Index Scan using tenk1_unique1 on tenk1 b (actual rows=0.90 loops=10)
Index Cond: (unique1 = g.g)
Filter: (ten <> 0)
Rows Removed by Filter: 0

The scan returned 0.90 rows per loop out of 1.00 fetched, yet the filter claims
it removed nothing. See the attached patch for complete examples.

The patch is a single-line change in show_instrumentation_count() plus two
tests. It is a concept, not a finished patch: I have not regenerated the other
expected outputs, where many values will change from "N" to "N.00" - you can
find a sketch for that in 0002-* file. Before going through that churn, I would
like to hear whether people agree that these counters should follow the same
rule as actual rows. The options I see are:

1. Always print two digits, as actual rows do now.
2. Leave the math to users and print exact totals without dividing by nloops.

The second approach is a much bigger change, with obvious pros and cons.
The first one is simpler and more conservative, and it is what the attached
patch does. In [1], depesz describes how the switch to fractional actual rows
affected his explain parser, and it needed only a small fix. So I expect this
change to be similarly harmless for tools.

Thoughts?

[1]
https://www.depesz.com/2025/02/28/waiting-for-postgresql-18-allow-explain-to-indicate-fractional-rows/

--
regards, Andrei Lepikhov,
pgEdge

Attachment Content-Type Size
0001-Switch-JOIN-and-SCAN-filter-explain-output-to-floati.patch text/plain 4.2 KB
0002-Adjust-regression-tests-to-fractional-Rows-Removed-b.patch text/plain 15.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message ZizhuanLiu X-MAN 2026-11-06 09:48:15 Re: support create index on virtual generated column.
Previous Message Nazir Bilal Yavuz 2026-11-06 08:53:21 Re: ci: Follow-up CI patches