agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add backend-level lock statistics
Date: Tue, 30 Jun 2026 08:07:25 +0000
Message-ID: <E1weTV7-000ksE-2z@gemulon.postgresql.org> (raw)
Add backend-level lock statistics
This commit adds per-backend lock statistics, providing the same
information as pg_stat_lock. It is now possible to retrieve those stats
(lock wait counts, wait times, and fast-path exceeded count) on a
per-backend basis.
This data can be retrieved with a new system function called
pg_stat_get_backend_lock(), that returns one tuple per lock type based
on the PID provided in input. Like pg_stat_get_backend_io(), this is
useful if joined with pg_stat_activity to get a live picture of the
locks behavior for each running backend.
pgstat_flush_backend() gains a new flag value, able to control the flush
of the lock stats.
This commit is straight-forward, relying on the infrastructure provided
by 9aea73fc61d4 (backend-level pgstats).
Bump catalog version. No need to touch PGSTAT_FILE_FORMAT_ID as backend
statistics are never written to disk.
Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Tatsuya Kawata <kawatatatsuya0913@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Tristan Partin <tristan@partin.io>
Reviewed-by: Rui Zhao <zhaorui126@gmail.com>
Discussion: https://postgr.es/m/aiAzEY+cMQb/W8yu@bdtpg
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/8c579bdc366dbca4fe9432a01408216133628c52
Modified Files
--------------
doc/src/sgml/monitoring.sgml | 19 ++++++++
src/backend/utils/activity/pgstat_backend.c | 72 +++++++++++++++++++++++++++++
src/backend/utils/activity/pgstat_lock.c | 4 ++
src/backend/utils/adt/pgstatfuncs.c | 29 +++++++++++-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 8 ++++
src/include/pgstat.h | 12 +++++
src/include/utils/pgstat_internal.h | 3 +-
src/test/regress/expected/stats.out | 12 +++++
src/test/regress/sql/stats.sql | 9 ++++
10 files changed, 166 insertions(+), 4 deletions(-)
Message-ID: <E1weTV7-000ksE-2z@gemulon.postgresql.org>
Permalink: ../E1weTV7-000ksE-2z@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1weTV7-000ksE-2z@gemulon.postgresql.org
reply
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: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Add backend-level lock statistics
In-Reply-To: <E1weTV7-000ksE-2z@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox