From: Etsuro Fujita <efujita@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix EXPLAIN ANALYZE for async-capable nodes.
Date: Wed, 12 May 2021 05:05:42 +0000
Message-ID: <E1lgh42-0002Ab-5M@gemulon.postgresql.org> (raw)
Fix EXPLAIN ANALYZE for async-capable nodes.
EXPLAIN ANALYZE for an async-capable ForeignScan node associated with
postgres_fdw is done just by using instrumentation for ExecProcNode()
called from the node's callbacks, causing the following problems:
1) If the remote table to scan is empty, the node is incorrectly
considered as "never executed" by the command even if the node is
executed, as ExecProcNode() isn't called from the node's callbacks at
all in that case.
2) The command fails to collect timings for things other than
ExecProcNode() done in the node, such as creating a cursor for the
node's remote query.
To fix these problems, add instrumentation for async-capable nodes, and
modify postgres_fdw accordingly.
My oversight in commit 27e1f1456.
While at it, update a comment for the AsyncRequest struct in execnodes.h
and the documentation for the ForeignAsyncRequest API in fdwhandler.sgml
to match the code in ExecAsyncAppendResponse() in nodeAppend.c, and fix
typos in comments in nodeAppend.c.
Per report from Andrey Lepikhov, though I didn't use his patch.
Reviewed-by: Andrey Lepikhov
Discussion: https://postgr.es/m/2eb662bb-105d-fc20-7412-2f027cc3ca72%40postgrespro.ru
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a363bc6da96b14d27e1cae1bae97242eb6ade5e6
Modified Files
--------------
contrib/auto_explain/auto_explain.c | 2 +-
contrib/pg_stat_statements/pg_stat_statements.c | 2 +-
contrib/postgres_fdw/expected/postgres_fdw.out | 39 +++++++++++++++++++++----
contrib/postgres_fdw/postgres_fdw.c | 9 ++++--
contrib/postgres_fdw/sql/postgres_fdw.sql | 21 +++++++++----
doc/src/sgml/fdwhandler.sgml | 2 +-
src/backend/executor/execAsync.c | 30 +++++++++++++++++++
src/backend/executor/execMain.c | 2 +-
src/backend/executor/execProcnode.c | 3 +-
src/backend/executor/instrument.c | 21 ++++++++++++-
src/backend/executor/nodeAppend.c | 12 ++++----
src/backend/executor/nodeForeignscan.c | 7 +++++
src/include/executor/instrument.h | 5 +++-
src/include/nodes/execnodes.h | 5 +++-
14 files changed, 134 insertions(+), 26 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: efujita@postgresql.org
Subject: Re: pgsql: Fix EXPLAIN ANALYZE for async-capable nodes.
In-Reply-To: <E1lgh42-0002Ab-5M@gemulon.postgresql.org>
References: <E1lgh42-0002Ab-5M@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox