Skip to content

Commit ce5bcc4

Browse files
committed
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 eaf5027, 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 cf54a2c 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
1 parent eaf5027 commit ce5bcc4

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

contrib/pg_stat_statements/expected/oldextversions.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ AlTER EXTENSION pg_stat_statements UPDATE TO '1.12';
385385
wal_records | bigint | | |
386386
wal_fpi | bigint | | |
387387
wal_bytes | numeric | | |
388+
wal_buffers_full | bigint | | |
388389
jit_functions | bigint | | |
389390
jit_generation_time | double precision | | |
390391
jit_inlining_count | bigint | | |

contrib/pg_stat_statements/pg_stat_statements--1.11--1.12.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ CREATE FUNCTION pg_stat_statements(IN showtext boolean,
5050
OUT wal_records int8,
5151
OUT wal_fpi int8,
5252
OUT wal_bytes numeric,
53+
OUT wal_buffers_full int8,
5354
OUT jit_functions int8,
5455
OUT jit_generation_time float8,
5556
OUT jit_inlining_count int8,

contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ typedef struct Counters
187187
int64 wal_records; /* # of WAL records generated */
188188
int64 wal_fpi; /* # of WAL full page images generated */
189189
uint64 wal_bytes; /* total amount of WAL generated in bytes */
190+
int64 wal_buffers_full; /* # of times the WAL buffers became full */
190191
int64 jit_functions; /* total number of JIT functions emitted */
191192
double jit_generation_time; /* total time to generate jit code */
192193
int64 jit_inlining_count; /* number of times inlining time has been
@@ -1465,6 +1466,7 @@ pgss_store(const char *query, uint64 queryId,
14651466
entry->counters.wal_records += walusage->wal_records;
14661467
entry->counters.wal_fpi += walusage->wal_fpi;
14671468
entry->counters.wal_bytes += walusage->wal_bytes;
1469+
entry->counters.wal_buffers_full += walusage->wal_buffers_full;
14681470
if (jitusage)
14691471
{
14701472
entry->counters.jit_functions += jitusage->created_functions;
@@ -1557,8 +1559,8 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS)
15571559
#define PG_STAT_STATEMENTS_COLS_V1_9 33
15581560
#define PG_STAT_STATEMENTS_COLS_V1_10 43
15591561
#define PG_STAT_STATEMENTS_COLS_V1_11 49
1560-
#define PG_STAT_STATEMENTS_COLS_V1_12 51
1561-
#define PG_STAT_STATEMENTS_COLS 51 /* maximum of above */
1562+
#define PG_STAT_STATEMENTS_COLS_V1_12 52
1563+
#define PG_STAT_STATEMENTS_COLS 52 /* maximum of above */
15621564

15631565
/*
15641566
* Retrieve statement statistics.
@@ -1955,6 +1957,10 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
19551957
Int32GetDatum(-1));
19561958
values[i++] = wal_bytes;
19571959
}
1960+
if (api_version >= PGSS_V1_12)
1961+
{
1962+
values[i++] = Int64GetDatumFast(tmp.wal_buffers_full);
1963+
}
19581964
if (api_version >= PGSS_V1_10)
19591965
{
19601966
values[i++] = Int64GetDatumFast(tmp.jit_functions);

doc/src/sgml/pgstatstatements.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,15 @@
436436
</para></entry>
437437
</row>
438438

439+
<row>
440+
<entry role="catalog_table_entry"><para role="column_definition">
441+
<structfield>wal_buffers_full</structfield> <type>bigint</type>
442+
</para>
443+
<para>
444+
Number of times the WAL buffers became full
445+
</para></entry>
446+
</row>
447+
439448
<row>
440449
<entry role="catalog_table_entry"><para role="column_definition">
441450
<structfield>jit_functions</structfield> <type>bigint</type>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy