From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Look up backend type in pg_signal_backend() more cheaply.
Date: Wed, 27 Nov 2024 16:34:28 +0000
Message-ID: <E1tGKzk-003m5a-LO@gemulon.postgresql.org> (raw)
Look up backend type in pg_signal_backend() more cheaply.
Commit ccd38024bc, which introduced the pg_signal_autovacuum_worker
role, added a call to pgstat_get_beentry_by_proc_number() for the
purpose of determining whether the process is an autovacuum worker.
This function calls pgstat_read_current_status(), which can be
fairly expensive and may return cached, out-of-date information.
Since we just need to look up the target backend's BackendType, and
we already know its ProcNumber, we can instead inspect the
BackendStatusArray directly, which is much less expensive and
possibly more up-to-date. There are some caveats with this
approach (which are documented in the code), but it's still
substantially better than before.
Reported-by: Andres Freund
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/ujenaa2uabzfkwxwmfifawzdozh3ljr7geozlhftsuosgm7n7q%40g3utqqyyosb6
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/61171a632d10ad7abe1d7ad891176266cc5ef0e1
Modified Files
--------------
src/backend/storage/ipc/signalfuncs.c | 4 ++--
src/backend/utils/activity/backend_status.c | 25 +++++++++++++++++++++++++
src/include/utils/backend_status.h | 1 +
3 files changed, 28 insertions(+), 2 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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Look up backend type in pg_signal_backend() more cheaply.
In-Reply-To: <E1tGKzk-003m5a-LO@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