Re: [PATCH] Add memory/disk usage for Function Scan nodes in EXPLAIN

From: Tatsuya Kawata <kawatatatsuya0913(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Yash Jadhav <yash(dot)jadhav8008(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Add memory/disk usage for Function Scan nodes in EXPLAIN
Date: 2026-10-13 14:37:58
Message-ID: CAHza6qe7hRr-H9N-xrRMWvQwqnrnP05OgGO9xHLE1TWD=Wd1aA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi David,

> That doesn't seem great. On checking, I see Material has the same
> issue, but that's not been highlighted by the buildfarm members
> running debug_parallel_query = regress due to lack of EXPLAIN ANALYZE
> test that has a Material node. I've just posted a patch to fix that in
> [1]. Can you follow that code and resolve this issue in your patch?

Thanks for committing the Material patch! v4 Attached.
The main changes from v3 are:

- As is done for Material, each worker now copies its statistics into
shared memory in ExecEndFunctionScan(), and EXPLAIN ANALYZE shows them
per worker.

- I changed how the statistics are kept, so that the workers and EXPLAIN
use the same values. The tuplestore returned by
ExecMakeTableFunctionResult() already holds the whole result set of
the function and doesn't grow after that, so its statistics are taken
right after it's returned, and used to update the per-function maximum
and the node-level values. EXPLAIN just reads the leader's values, and
each worker copies its own into shared memory when it ends.

This made v3-0001's saving of the statistics before a rescan discards
the tuplestore, and moving FunctionScanPerFuncState into execnodes.h,
unnecessary, so I've merged the patches into one. The statistics are
only collected for EXPLAIN ANALYZE.

- Removed max_parallel_workers_per_gather = 0 from the tests. I've
confirmed make check passes with debug_parallel_query = regress too.

Regards,
Tatsuya Kawata

Attachment Content-Type Size
v4-0001-Add-memory-disk-usage-for-Function-Scan-nodes-in-.patch application/x-patch 23.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2026-10-13 14:40:36 Re: index prefetching
Previous Message Richard Guo 2026-10-13 14:34:50 Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned