mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
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 sinceeaf502747b
, 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 commitcf54a2c002
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
This commit is contained in:
@ -385,6 +385,7 @@ AlTER EXTENSION pg_stat_statements UPDATE TO '1.12';
|
|||||||
wal_records | bigint | | |
|
wal_records | bigint | | |
|
||||||
wal_fpi | bigint | | |
|
wal_fpi | bigint | | |
|
||||||
wal_bytes | numeric | | |
|
wal_bytes | numeric | | |
|
||||||
|
wal_buffers_full | bigint | | |
|
||||||
jit_functions | bigint | | |
|
jit_functions | bigint | | |
|
||||||
jit_generation_time | double precision | | |
|
jit_generation_time | double precision | | |
|
||||||
jit_inlining_count | bigint | | |
|
jit_inlining_count | bigint | | |
|
||||||
|
@ -50,6 +50,7 @@ CREATE FUNCTION pg_stat_statements(IN showtext boolean,
|
|||||||
OUT wal_records int8,
|
OUT wal_records int8,
|
||||||
OUT wal_fpi int8,
|
OUT wal_fpi int8,
|
||||||
OUT wal_bytes numeric,
|
OUT wal_bytes numeric,
|
||||||
|
OUT wal_buffers_full int8,
|
||||||
OUT jit_functions int8,
|
OUT jit_functions int8,
|
||||||
OUT jit_generation_time float8,
|
OUT jit_generation_time float8,
|
||||||
OUT jit_inlining_count int8,
|
OUT jit_inlining_count int8,
|
||||||
|
@ -187,6 +187,7 @@ typedef struct Counters
|
|||||||
int64 wal_records; /* # of WAL records generated */
|
int64 wal_records; /* # of WAL records generated */
|
||||||
int64 wal_fpi; /* # of WAL full page images generated */
|
int64 wal_fpi; /* # of WAL full page images generated */
|
||||||
uint64 wal_bytes; /* total amount of WAL generated in bytes */
|
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 */
|
int64 jit_functions; /* total number of JIT functions emitted */
|
||||||
double jit_generation_time; /* total time to generate jit code */
|
double jit_generation_time; /* total time to generate jit code */
|
||||||
int64 jit_inlining_count; /* number of times inlining time has been
|
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_records += walusage->wal_records;
|
||||||
entry->counters.wal_fpi += walusage->wal_fpi;
|
entry->counters.wal_fpi += walusage->wal_fpi;
|
||||||
entry->counters.wal_bytes += walusage->wal_bytes;
|
entry->counters.wal_bytes += walusage->wal_bytes;
|
||||||
|
entry->counters.wal_buffers_full += walusage->wal_buffers_full;
|
||||||
if (jitusage)
|
if (jitusage)
|
||||||
{
|
{
|
||||||
entry->counters.jit_functions += jitusage->created_functions;
|
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_9 33
|
||||||
#define PG_STAT_STATEMENTS_COLS_V1_10 43
|
#define PG_STAT_STATEMENTS_COLS_V1_10 43
|
||||||
#define PG_STAT_STATEMENTS_COLS_V1_11 49
|
#define PG_STAT_STATEMENTS_COLS_V1_11 49
|
||||||
#define PG_STAT_STATEMENTS_COLS_V1_12 51
|
#define PG_STAT_STATEMENTS_COLS_V1_12 52
|
||||||
#define PG_STAT_STATEMENTS_COLS 51 /* maximum of above */
|
#define PG_STAT_STATEMENTS_COLS 52 /* maximum of above */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve statement statistics.
|
* Retrieve statement statistics.
|
||||||
@ -1955,6 +1957,10 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
|
|||||||
Int32GetDatum(-1));
|
Int32GetDatum(-1));
|
||||||
values[i++] = wal_bytes;
|
values[i++] = wal_bytes;
|
||||||
}
|
}
|
||||||
|
if (api_version >= PGSS_V1_12)
|
||||||
|
{
|
||||||
|
values[i++] = Int64GetDatumFast(tmp.wal_buffers_full);
|
||||||
|
}
|
||||||
if (api_version >= PGSS_V1_10)
|
if (api_version >= PGSS_V1_10)
|
||||||
{
|
{
|
||||||
values[i++] = Int64GetDatumFast(tmp.jit_functions);
|
values[i++] = Int64GetDatumFast(tmp.jit_functions);
|
||||||
|
@ -436,6 +436,15 @@
|
|||||||
</para></entry>
|
</para></entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
|
<structfield>wal_buffers_full</structfield> <type>bigint</type>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Number of times the WAL buffers became full
|
||||||
|
</para></entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry role="catalog_table_entry"><para role="column_definition">
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
<structfield>jit_functions</structfield> <type>bigint</type>
|
<structfield>jit_functions</structfield> <type>bigint</type>
|
||||||
|
Reference in New Issue
Block a user