pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add backend-level statistics to pgstats
Date: Thu, 19 Dec 2024 04:20:57 +0000
Message-ID: <E1tO81x-000Ih9-76@gemulon.postgresql.org> (raw)

Add backend-level statistics to pgstats

This adds a new variable-numbered statistics kind in pgstats, where the
object ID key of the stats entries is based on the proc number of the
backends.  This acts as an upper-bound for the number of stats entries
that can exist at once.  The entries are created when a backend starts
after authentication succeeds, and are removed when the backend exits,
making the stats entry exist for as long as their backend is up and
running.  These are not written to the pgstats file at shutdown (note
that write_to_file is disabled, as a safety measure).

Currently, these stats include only information about the I/O generated
by a backend, using the same layer as pg_stat_io, except that it is now
possible to know how much activity is happening in each backend rather
than an overall aggregate of all the activity.  A function called
pg_stat_get_backend_io() is added to access this data depending on the
PID of a backend.  The existing structure could be expanded in the
future to add more information about other statistics related to
backends, depending on requirements or ideas.

Auxiliary processes are not included in this set of statistics.  These
are less interesting to have than normal backends as they have dedicated
entries in pg_stat_io, and stats kinds of their own.

This commit includes also pg_stat_reset_backend_stats(), function able
to reset all the stats associated to a single backend.

Bump catalog version and PGSTAT_FILE_FORMAT_ID.

Author: Bertrand Drouvot
Reviewed-by: Álvaro Herrera, Kyotaro Horiguchi, Michael Paquier, Nazir
Bilal Yavuz
Discussion: https://postgr.es/m/ZtXR+CtkEVVE/LHF@ip-10-97-1-34.eu-west-3.compute.internal

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9aea73fc61d4e77e000724ce0b2f896590a10e03

Modified Files
--------------
doc/src/sgml/config.sgml                     |   8 +-
doc/src/sgml/monitoring.sgml                 |  39 ++++++
src/backend/catalog/system_functions.sql     |   2 +
src/backend/utils/activity/Makefile          |   1 +
src/backend/utils/activity/backend_status.c  |   4 +
src/backend/utils/activity/meson.build       |   1 +
src/backend/utils/activity/pgstat.c          |  21 +++
src/backend/utils/activity/pgstat_backend.c  | 188 +++++++++++++++++++++++++++
src/backend/utils/activity/pgstat_io.c       |  25 ++--
src/backend/utils/activity/pgstat_relation.c |   2 +
src/backend/utils/adt/pgstatfuncs.c          |  99 +++++++++++++-
src/include/catalog/catversion.h             |   2 +-
src/include/catalog/pg_proc.dat              |  13 ++
src/include/pgstat.h                         |  36 ++++-
src/include/utils/pgstat_internal.h          |  14 ++
src/test/regress/expected/stats.out          |  82 +++++++++++-
src/test/regress/sql/stats.sql               |  42 +++++-
src/tools/pgindent/typedefs.list             |   3 +
18 files changed, 553 insertions(+), 29 deletions(-)



Message-ID: <E1tO81x-000Ih9-76@gemulon.postgresql.org>
Permalink:  ../E1tO81x-000Ih9-76@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tO81x-000Ih9-76@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 statistics to pgstats
  In-Reply-To: <E1tO81x-000Ih9-76@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