diff options
author | Michael Paquier <michael@paquier.xyz> | 2023-10-19 14:03:31 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2023-10-19 14:03:31 +0900 |
commit | 5147ab1dd34ad81c169c85fa3c7d11a782a1555b (patch) | |
tree | 2c3652782e17f76a2c96d08605069e0d415a5676 /contrib/pg_stat_statements/pg_stat_statements.c | |
parent | 295c36c0c1fa7b6befd0a3525c7f109e838c9448 (diff) | |
download | postgresql-5147ab1dd34ad81c169c85fa3c7d11a782a1555b.tar.gz postgresql-5147ab1dd34ad81c169c85fa3c7d11a782a1555b.zip |
pg_stat_statements: Add local_blk_{read|write}_time
This commit adds to pg_stat_statements the two new fields for local
buffers introduced by 295c36c0c1fa, adding the time spent to read and
write these blocks. These are similar to what is done for temp and
shared blocks. This information available only if track_io_timing is
enabled.
Like for 5a3423ad8ee17, no version bump is required in the module.
Author: Nazir Bilal Yavuz
Reviewed-by: Robert Haas, Melanie Plageman
Discussion: https://postgr.es/m/CAN55FZ19Ss279mZuqGbuUNxka0iPbLgYuOQXqAKewrjNrp27VA@mail.gmail.com
Diffstat (limited to 'contrib/pg_stat_statements/pg_stat_statements.c')
-rw-r--r-- | contrib/pg_stat_statements/pg_stat_statements.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index 11e6f25b752..baff87b49e1 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -184,6 +184,10 @@ typedef struct Counters * in msec */ double shared_blk_write_time; /* time spent writing shared blocks, * in msec */ + double local_blk_read_time; /* time spent reading local blocks, in + * msec */ + double local_blk_write_time; /* time spent writing local blocks, in + * msec */ double temp_blk_read_time; /* time spent reading temp blocks, in msec */ double temp_blk_write_time; /* time spent writing temp blocks, in * msec */ @@ -1395,6 +1399,8 @@ pgss_store(const char *query, uint64 queryId, e->counters.temp_blks_written += bufusage->temp_blks_written; e->counters.shared_blk_read_time += INSTR_TIME_GET_MILLISEC(bufusage->shared_blk_read_time); e->counters.shared_blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->shared_blk_write_time); + e->counters.local_blk_read_time += INSTR_TIME_GET_MILLISEC(bufusage->local_blk_read_time); + e->counters.local_blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->local_blk_write_time); e->counters.temp_blk_read_time += INSTR_TIME_GET_MILLISEC(bufusage->temp_blk_read_time); e->counters.temp_blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->temp_blk_write_time); e->counters.usage += USAGE_EXEC(total_time); @@ -1472,8 +1478,8 @@ pg_stat_statements_reset(PG_FUNCTION_ARGS) #define PG_STAT_STATEMENTS_COLS_V1_8 32 #define PG_STAT_STATEMENTS_COLS_V1_9 33 #define PG_STAT_STATEMENTS_COLS_V1_10 43 -#define PG_STAT_STATEMENTS_COLS_V1_11 45 -#define PG_STAT_STATEMENTS_COLS 45 /* maximum of above */ +#define PG_STAT_STATEMENTS_COLS_V1_11 47 +#define PG_STAT_STATEMENTS_COLS 47 /* maximum of above */ /* * Retrieve statement statistics. @@ -1828,6 +1834,11 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo, values[i++] = Float8GetDatumFast(tmp.shared_blk_read_time); values[i++] = Float8GetDatumFast(tmp.shared_blk_write_time); } + if (api_version >= PGSS_V1_11) + { + values[i++] = Float8GetDatumFast(tmp.local_blk_read_time); + values[i++] = Float8GetDatumFast(tmp.local_blk_write_time); + } if (api_version >= PGSS_V1_10) { values[i++] = Float8GetDatumFast(tmp.temp_blk_read_time); |