diff options
author | Michael Paquier <michael@paquier.xyz> | 2025-02-17 13:55:17 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2025-02-17 13:55:17 +0900 |
commit | ce5bcc4a9f26484746f82d23584c8e342cba9b10 (patch) | |
tree | e88c17645b811c373cca809801ad3874941e7589 /contrib/pg_stat_statements/pg_stat_statements.c | |
parent | eaf502747bacee0122668eb1ba3979f86b8d8342 (diff) | |
download | postgresql-ce5bcc4a9f26484746f82d23584c8e342cba9b10.tar.gz postgresql-ce5bcc4a9f26484746f82d23584c8e342cba9b10.zip |
pg_stat_statements: Add wal_buffers_full
wal_buffers_full tracks the number of times WAL buffers become full,
giving hints to be able to tune the GUC wal_buffers.
Up to now, this information was only available in pg_stat_wal. With
this field available in WalUsage since eaf502747bac, exposing it in
pg_stat_statements is straight-forward, and it offers more granularity
at query level.
pg_stat_statements does not need a version bump as one has been done in
commit cf54a2c00254 for this development cycle.
Author: Bertrand Drouvot
Reviewed-by: Ilia Evdokimov
Discussion: https://postgr.es/m/Z6SOha5YFFgvpwQY@ip-10-97-1-34.eu-west-3.compute.internal
Diffstat (limited to 'contrib/pg_stat_statements/pg_stat_statements.c')
-rw-r--r-- | contrib/pg_stat_statements/pg_stat_statements.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index bebf8134eb0..4a3e855ce90 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -187,6 +187,7 @@ typedef struct Counters int64 wal_records; /* # of WAL records generated */ int64 wal_fpi; /* # of WAL full page images generated */ uint64 wal_bytes; /* total amount of WAL generated in bytes */ + int64 wal_buffers_full; /* # of times the WAL buffers became full */ int64 jit_functions; /* total number of JIT functions emitted */ double jit_generation_time; /* total time to generate jit code */ int64 jit_inlining_count; /* number of times inlining time has been @@ -1465,6 +1466,7 @@ pgss_store(const char *query, uint64 queryId, entry->counters.wal_records += walusage->wal_records; entry->counters.wal_fpi += walusage->wal_fpi; entry->counters.wal_bytes += walusage->wal_bytes; + entry->counters.wal_buffers_full += walusage->wal_buffers_full; if (jitusage) { entry->counters.jit_functions += jitusage->created_functions; @@ -1557,8 +1559,8 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS) #define PG_STAT_STATEMENTS_COLS_V1_9 33 #define PG_STAT_STATEMENTS_COLS_V1_10 43 #define PG_STAT_STATEMENTS_COLS_V1_11 49 -#define PG_STAT_STATEMENTS_COLS_V1_12 51 -#define PG_STAT_STATEMENTS_COLS 51 /* maximum of above */ +#define PG_STAT_STATEMENTS_COLS_V1_12 52 +#define PG_STAT_STATEMENTS_COLS 52 /* maximum of above */ /* * Retrieve statement statistics. @@ -1955,6 +1957,10 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo, Int32GetDatum(-1)); values[i++] = wal_bytes; } + if (api_version >= PGSS_V1_12) + { + values[i++] = Int64GetDatumFast(tmp.wal_buffers_full); + } if (api_version >= PGSS_V1_10) { values[i++] = Int64GetDatumFast(tmp.jit_functions); |