mirror of https://github.com/postgres/postgres
pg_stat_statements: Add local_blk_{read|write}_time
This commit adds to pg_stat_statements the two new fields for local buffers introduced by295c36c0c1
, 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 for5a3423ad8e
, 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
This commit is contained in:
parent
295c36c0c1
commit
5147ab1dd3
|
@ -286,6 +286,8 @@ AlTER EXTENSION pg_stat_statements UPDATE TO '1.11';
|
|||
temp_blks_written | bigint | | |
|
||||
shared_blk_read_time | double precision | | |
|
||||
shared_blk_write_time | double precision | | |
|
||||
local_blk_read_time | double precision | | |
|
||||
local_blk_write_time | double precision | | |
|
||||
temp_blk_read_time | double precision | | |
|
||||
temp_blk_write_time | double precision | | |
|
||||
wal_records | bigint | | |
|
||||
|
|
|
@ -43,6 +43,8 @@ CREATE FUNCTION pg_stat_statements(IN showtext boolean,
|
|||
OUT temp_blks_written int8,
|
||||
OUT shared_blk_read_time float8,
|
||||
OUT shared_blk_write_time float8,
|
||||
OUT local_blk_read_time float8,
|
||||
OUT local_blk_write_time float8,
|
||||
OUT temp_blk_read_time float8,
|
||||
OUT temp_blk_write_time float8,
|
||||
OUT wal_records int8,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -353,6 +353,26 @@
|
|||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>local_blk_read_time</structfield> <type>double precision</type>
|
||||
</para>
|
||||
<para>
|
||||
Total time the statement spent reading local blocks, in milliseconds
|
||||
(if <xref linkend="guc-track-io-timing"/> is enabled, otherwise zero)
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>local_blk_write_time</structfield> <type>double precision</type>
|
||||
</para>
|
||||
<para>
|
||||
Total time the statement spent writing local blocks, in milliseconds
|
||||
(if <xref linkend="guc-track-io-timing"/> is enabled, otherwise zero)
|
||||
</para></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry"><para role="column_definition">
|
||||
<structfield>temp_blk_read_time</structfield> <type>double precision</type>
|
||||
|
|
Loading…
Reference in New Issue