Remove io prefix from pg_stat_io columns
a9c70b46 added the statistics view pg_stat_io which contained columns "io_context" and "io_object". Given that the columns are in the pg_stat_io view, the "io" prefix is somewhat redundant, so remove it. The code variables referring to these fields are kept unchanged so as they can keep their context about I/O. Bump catalog version. Author: Melanie Plageman Reviewed-by: Kyotaro Horiguchi, Fabrízio de Royes Mello Discussion: https://postgr.es/m/CAAKRu_aAQoJWrvT2BYYQvJChFKra_O-5ra3jhzKJZqWsTR1CPQ@mail.gmail.com
This commit is contained in:
parent
eab2d3147e
commit
0ecb87e1fa
@ -80,7 +80,7 @@ INSERT INTO heaptest (a, b)
|
|||||||
SET allow_in_place_tablespaces = true;
|
SET allow_in_place_tablespaces = true;
|
||||||
CREATE TABLESPACE regress_test_stats_tblspc LOCATION '';
|
CREATE TABLESPACE regress_test_stats_tblspc LOCATION '';
|
||||||
SELECT sum(reads) AS stats_bulkreads_before
|
SELECT sum(reads) AS stats_bulkreads_before
|
||||||
FROM pg_stat_io WHERE io_context = 'bulkread' \gset
|
FROM pg_stat_io WHERE context = 'bulkread' \gset
|
||||||
ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc;
|
ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc;
|
||||||
-- Check that valid options are not rejected nor corruption reported
|
-- Check that valid options are not rejected nor corruption reported
|
||||||
-- for a non-empty table
|
-- for a non-empty table
|
||||||
@ -114,7 +114,7 @@ SELECT pg_stat_force_next_flush();
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT sum(reads) AS stats_bulkreads_after
|
SELECT sum(reads) AS stats_bulkreads_after
|
||||||
FROM pg_stat_io WHERE io_context = 'bulkread' \gset
|
FROM pg_stat_io WHERE context = 'bulkread' \gset
|
||||||
SELECT :stats_bulkreads_after > :stats_bulkreads_before;
|
SELECT :stats_bulkreads_after > :stats_bulkreads_before;
|
||||||
?column?
|
?column?
|
||||||
----------
|
----------
|
||||||
|
@ -40,7 +40,7 @@ INSERT INTO heaptest (a, b)
|
|||||||
SET allow_in_place_tablespaces = true;
|
SET allow_in_place_tablespaces = true;
|
||||||
CREATE TABLESPACE regress_test_stats_tblspc LOCATION '';
|
CREATE TABLESPACE regress_test_stats_tblspc LOCATION '';
|
||||||
SELECT sum(reads) AS stats_bulkreads_before
|
SELECT sum(reads) AS stats_bulkreads_before
|
||||||
FROM pg_stat_io WHERE io_context = 'bulkread' \gset
|
FROM pg_stat_io WHERE context = 'bulkread' \gset
|
||||||
ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc;
|
ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc;
|
||||||
|
|
||||||
-- Check that valid options are not rejected nor corruption reported
|
-- Check that valid options are not rejected nor corruption reported
|
||||||
@ -55,7 +55,7 @@ SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 0, endblock :=
|
|||||||
-- causing an additional bulkread, which should be reflected in pg_stat_io.
|
-- causing an additional bulkread, which should be reflected in pg_stat_io.
|
||||||
SELECT pg_stat_force_next_flush();
|
SELECT pg_stat_force_next_flush();
|
||||||
SELECT sum(reads) AS stats_bulkreads_after
|
SELECT sum(reads) AS stats_bulkreads_after
|
||||||
FROM pg_stat_io WHERE io_context = 'bulkread' \gset
|
FROM pg_stat_io WHERE context = 'bulkread' \gset
|
||||||
SELECT :stats_bulkreads_after > :stats_bulkreads_before;
|
SELECT :stats_bulkreads_after > :stats_bulkreads_before;
|
||||||
|
|
||||||
CREATE ROLE regress_heaptest_role;
|
CREATE ROLE regress_heaptest_role;
|
||||||
|
@ -3754,7 +3754,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
|||||||
<row>
|
<row>
|
||||||
<entry role="catalog_table_entry">
|
<entry role="catalog_table_entry">
|
||||||
<para role="column_definition">
|
<para role="column_definition">
|
||||||
<structfield>io_object</structfield> <type>text</type>
|
<structfield>object</structfield> <type>text</type>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Target object of an I/O operation. Possible values are:
|
Target object of an I/O operation. Possible values are:
|
||||||
@ -3777,7 +3777,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
|||||||
<row>
|
<row>
|
||||||
<entry role="catalog_table_entry">
|
<entry role="catalog_table_entry">
|
||||||
<para role="column_definition">
|
<para role="column_definition">
|
||||||
<structfield>io_context</structfield> <type>text</type>
|
<structfield>context</structfield> <type>text</type>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The context of an I/O operation. Possible values are:
|
The context of an I/O operation. Possible values are:
|
||||||
@ -3786,10 +3786,10 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<literal>normal</literal>: The default or standard
|
<literal>normal</literal>: The default or standard
|
||||||
<varname>io_context</varname> for a type of I/O operation. For
|
<varname>context</varname> for a type of I/O operation. For
|
||||||
example, by default, relation data is read into and written out from
|
example, by default, relation data is read into and written out from
|
||||||
shared buffers. Thus, reads and writes of relation data to and from
|
shared buffers. Thus, reads and writes of relation data to and from
|
||||||
shared buffers are tracked in <varname>io_context</varname>
|
shared buffers are tracked in <varname>context</varname>
|
||||||
<literal>normal</literal>.
|
<literal>normal</literal>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -3798,7 +3798,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
|||||||
<literal>vacuum</literal>: I/O operations performed outside of shared
|
<literal>vacuum</literal>: I/O operations performed outside of shared
|
||||||
buffers while vacuuming and analyzing permanent relations. Temporary
|
buffers while vacuuming and analyzing permanent relations. Temporary
|
||||||
table vacuums use the same local buffer pool as other temporary table
|
table vacuums use the same local buffer pool as other temporary table
|
||||||
IO operations and are tracked in <varname>io_context</varname>
|
IO operations and are tracked in <varname>context</varname>
|
||||||
<literal>normal</literal>.
|
<literal>normal</literal>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@ -3929,9 +3929,9 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
|||||||
buffer in order to make it available for another use.
|
buffer in order to make it available for another use.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
In <varname>io_context</varname> <literal>normal</literal>, this counts
|
In <varname>context</varname> <literal>normal</literal>, this counts
|
||||||
the number of times a block was evicted from a buffer and replaced with
|
the number of times a block was evicted from a buffer and replaced with
|
||||||
another block. In <varname>io_context</varname>s
|
another block. In <varname>context</varname>s
|
||||||
<literal>bulkwrite</literal>, <literal>bulkread</literal>, and
|
<literal>bulkwrite</literal>, <literal>bulkread</literal>, and
|
||||||
<literal>vacuum</literal>, this counts the number of times a block was
|
<literal>vacuum</literal>, this counts the number of times a block was
|
||||||
evicted from shared buffers in order to add the shared buffer to a
|
evicted from shared buffers in order to add the shared buffer to a
|
||||||
@ -3949,7 +3949,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
|||||||
The number of times an existing buffer in a size-limited ring buffer
|
The number of times an existing buffer in a size-limited ring buffer
|
||||||
outside of shared buffers was reused as part of an I/O operation in the
|
outside of shared buffers was reused as part of an I/O operation in the
|
||||||
<literal>bulkread</literal>, <literal>bulkwrite</literal>, or
|
<literal>bulkread</literal>, <literal>bulkwrite</literal>, or
|
||||||
<literal>vacuum</literal> <varname>io_context</varname>s.
|
<literal>vacuum</literal> <varname>context</varname>s.
|
||||||
</para>
|
</para>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
@ -3961,7 +3961,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Number of <literal>fsync</literal> calls. These are only tracked in
|
Number of <literal>fsync</literal> calls. These are only tracked in
|
||||||
<varname>io_context</varname> <literal>normal</literal>.
|
<varname>context</varname> <literal>normal</literal>.
|
||||||
</para>
|
</para>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
@ -3997,7 +3997,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
|||||||
in some I/O contexts. These rows are omitted from the view. For example, the
|
in some I/O contexts. These rows are omitted from the view. For example, the
|
||||||
checkpointer does not checkpoint temporary tables, so there will be no rows
|
checkpointer does not checkpoint temporary tables, so there will be no rows
|
||||||
for <varname>backend_type</varname> <literal>checkpointer</literal> and
|
for <varname>backend_type</varname> <literal>checkpointer</literal> and
|
||||||
<varname>io_object</varname> <literal>temp relation</literal>.
|
<varname>object</varname> <literal>temp relation</literal>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -4005,7 +4005,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
|
|||||||
backend types or on certain I/O objects and/or in certain I/O contexts.
|
backend types or on certain I/O objects and/or in certain I/O contexts.
|
||||||
These cells will be NULL. For example, temporary tables are not
|
These cells will be NULL. For example, temporary tables are not
|
||||||
<literal>fsync</literal>ed, so <varname>fsyncs</varname> will be NULL for
|
<literal>fsync</literal>ed, so <varname>fsyncs</varname> will be NULL for
|
||||||
<varname>io_object</varname> <literal>temp relation</literal>. Also, the
|
<varname>object</varname> <literal>temp relation</literal>. Also, the
|
||||||
background writer does not perform reads, so <varname>reads</varname> will
|
background writer does not perform reads, so <varname>reads</varname> will
|
||||||
be NULL in rows for <varname>backend_type</varname> <literal>background
|
be NULL in rows for <varname>backend_type</varname> <literal>background
|
||||||
writer</literal>.
|
writer</literal>.
|
||||||
|
@ -1125,8 +1125,8 @@ CREATE VIEW pg_stat_bgwriter AS
|
|||||||
CREATE VIEW pg_stat_io AS
|
CREATE VIEW pg_stat_io AS
|
||||||
SELECT
|
SELECT
|
||||||
b.backend_type,
|
b.backend_type,
|
||||||
b.io_object,
|
b.object,
|
||||||
b.io_context,
|
b.context,
|
||||||
b.reads,
|
b.reads,
|
||||||
b.read_time,
|
b.read_time,
|
||||||
b.writes,
|
b.writes,
|
||||||
|
@ -1262,8 +1262,8 @@ typedef enum io_stat_col
|
|||||||
{
|
{
|
||||||
IO_COL_INVALID = -1,
|
IO_COL_INVALID = -1,
|
||||||
IO_COL_BACKEND_TYPE,
|
IO_COL_BACKEND_TYPE,
|
||||||
IO_COL_IO_OBJECT,
|
IO_COL_OBJECT,
|
||||||
IO_COL_IO_CONTEXT,
|
IO_COL_CONTEXT,
|
||||||
IO_COL_READS,
|
IO_COL_READS,
|
||||||
IO_COL_READ_TIME,
|
IO_COL_READ_TIME,
|
||||||
IO_COL_WRITES,
|
IO_COL_WRITES,
|
||||||
@ -1394,8 +1394,8 @@ pg_stat_get_io(PG_FUNCTION_ARGS)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
values[IO_COL_BACKEND_TYPE] = bktype_desc;
|
values[IO_COL_BACKEND_TYPE] = bktype_desc;
|
||||||
values[IO_COL_IO_CONTEXT] = CStringGetTextDatum(context_name);
|
values[IO_COL_CONTEXT] = CStringGetTextDatum(context_name);
|
||||||
values[IO_COL_IO_OBJECT] = CStringGetTextDatum(obj_name);
|
values[IO_COL_OBJECT] = CStringGetTextDatum(obj_name);
|
||||||
values[IO_COL_RESET_TIME] = TimestampTzGetDatum(reset_time);
|
values[IO_COL_RESET_TIME] = TimestampTzGetDatum(reset_time);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -57,6 +57,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* yyyymmddN */
|
/* yyyymmddN */
|
||||||
#define CATALOG_VERSION_NO 202304111
|
#define CATALOG_VERSION_NO 202304211
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -5762,7 +5762,7 @@
|
|||||||
proparallel => 'r', prorettype => 'record', proargtypes => '',
|
proparallel => 'r', prorettype => 'record', proargtypes => '',
|
||||||
proallargtypes => '{text,text,text,int8,float8,int8,float8,int8,float8,int8,int8,int8,int8,int8,float8,timestamptz}',
|
proallargtypes => '{text,text,text,int8,float8,int8,float8,int8,float8,int8,int8,int8,int8,int8,float8,timestamptz}',
|
||||||
proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
|
proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
|
||||||
proargnames => '{backend_type,io_object,io_context,reads,read_time,writes,write_time,extends,extend_time,op_bytes,hits,evictions,reuses,fsyncs,fsync_time,stats_reset}',
|
proargnames => '{backend_type,object,context,reads,read_time,writes,write_time,extends,extend_time,op_bytes,hits,evictions,reuses,fsyncs,fsync_time,stats_reset}',
|
||||||
prosrc => 'pg_stat_get_io' },
|
prosrc => 'pg_stat_get_io' },
|
||||||
|
|
||||||
{ oid => '1136', descr => 'statistics: information about WAL activity',
|
{ oid => '1136', descr => 'statistics: information about WAL activity',
|
||||||
|
@ -1881,8 +1881,8 @@ pg_stat_gssapi| SELECT pid,
|
|||||||
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, gss_deleg, leader_pid, query_id)
|
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, gss_deleg, leader_pid, query_id)
|
||||||
WHERE (client_port IS NOT NULL);
|
WHERE (client_port IS NOT NULL);
|
||||||
pg_stat_io| SELECT backend_type,
|
pg_stat_io| SELECT backend_type,
|
||||||
io_object,
|
object,
|
||||||
io_context,
|
context,
|
||||||
reads,
|
reads,
|
||||||
read_time,
|
read_time,
|
||||||
writes,
|
writes,
|
||||||
@ -1896,7 +1896,7 @@ pg_stat_io| SELECT backend_type,
|
|||||||
fsyncs,
|
fsyncs,
|
||||||
fsync_time,
|
fsync_time,
|
||||||
stats_reset
|
stats_reset
|
||||||
FROM pg_stat_get_io() b(backend_type, io_object, io_context, reads, read_time, writes, write_time, extends, extend_time, op_bytes, hits, evictions, reuses, fsyncs, fsync_time, stats_reset);
|
FROM pg_stat_get_io() b(backend_type, object, context, reads, read_time, writes, write_time, extends, extend_time, op_bytes, hits, evictions, reuses, fsyncs, fsync_time, stats_reset);
|
||||||
pg_stat_progress_analyze| SELECT s.pid,
|
pg_stat_progress_analyze| SELECT s.pid,
|
||||||
s.datid,
|
s.datid,
|
||||||
d.datname,
|
d.datname,
|
||||||
|
@ -1137,10 +1137,10 @@ SELECT pg_stat_get_subscription_stats(NULL);
|
|||||||
-- Create a regular table and insert some data to generate IOCONTEXT_NORMAL
|
-- Create a regular table and insert some data to generate IOCONTEXT_NORMAL
|
||||||
-- extends.
|
-- extends.
|
||||||
SELECT sum(extends) AS io_sum_shared_before_extends
|
SELECT sum(extends) AS io_sum_shared_before_extends
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs
|
SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs
|
||||||
FROM pg_stat_io
|
FROM pg_stat_io
|
||||||
WHERE io_object = 'relation' \gset io_sum_shared_before_
|
WHERE object = 'relation' \gset io_sum_shared_before_
|
||||||
CREATE TABLE test_io_shared(a int);
|
CREATE TABLE test_io_shared(a int);
|
||||||
INSERT INTO test_io_shared SELECT i FROM generate_series(1,100)i;
|
INSERT INTO test_io_shared SELECT i FROM generate_series(1,100)i;
|
||||||
SELECT pg_stat_force_next_flush();
|
SELECT pg_stat_force_next_flush();
|
||||||
@ -1150,7 +1150,7 @@ SELECT pg_stat_force_next_flush();
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT sum(extends) AS io_sum_shared_after_extends
|
SELECT sum(extends) AS io_sum_shared_after_extends
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
SELECT :io_sum_shared_after_extends > :io_sum_shared_before_extends;
|
SELECT :io_sum_shared_after_extends > :io_sum_shared_before_extends;
|
||||||
?column?
|
?column?
|
||||||
----------
|
----------
|
||||||
@ -1164,7 +1164,7 @@ CHECKPOINT;
|
|||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs
|
SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs
|
||||||
FROM pg_stat_io
|
FROM pg_stat_io
|
||||||
WHERE io_object = 'relation' \gset io_sum_shared_after_
|
WHERE object = 'relation' \gset io_sum_shared_after_
|
||||||
SELECT :io_sum_shared_after_writes > :io_sum_shared_before_writes;
|
SELECT :io_sum_shared_after_writes > :io_sum_shared_before_writes;
|
||||||
?column?
|
?column?
|
||||||
----------
|
----------
|
||||||
@ -1181,13 +1181,13 @@ SELECT current_setting('fsync') = 'off'
|
|||||||
-- Change the tablespace so that the table is rewritten directly, then SELECT
|
-- Change the tablespace so that the table is rewritten directly, then SELECT
|
||||||
-- from it to cause it to be read back into shared buffers.
|
-- from it to cause it to be read back into shared buffers.
|
||||||
SELECT sum(reads) AS io_sum_shared_before_reads
|
SELECT sum(reads) AS io_sum_shared_before_reads
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
-- Do this in a transaction to prevent spurious failures due to concurrent accesses to our newly
|
-- Do this in a transaction to prevent spurious failures due to concurrent accesses to our newly
|
||||||
-- rewritten table, e.g. by autovacuum.
|
-- rewritten table, e.g. by autovacuum.
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE test_io_shared SET TABLESPACE regress_tblspace;
|
ALTER TABLE test_io_shared SET TABLESPACE regress_tblspace;
|
||||||
-- SELECT from the table so that the data is read into shared buffers and
|
-- SELECT from the table so that the data is read into shared buffers and
|
||||||
-- io_context 'normal', io_object 'relation' reads are counted.
|
-- context 'normal', object 'relation' reads are counted.
|
||||||
SELECT COUNT(*) FROM test_io_shared;
|
SELECT COUNT(*) FROM test_io_shared;
|
||||||
count
|
count
|
||||||
-------
|
-------
|
||||||
@ -1202,7 +1202,7 @@ SELECT pg_stat_force_next_flush();
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT sum(reads) AS io_sum_shared_after_reads
|
SELECT sum(reads) AS io_sum_shared_after_reads
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
SELECT :io_sum_shared_after_reads > :io_sum_shared_before_reads;
|
SELECT :io_sum_shared_after_reads > :io_sum_shared_before_reads;
|
||||||
?column?
|
?column?
|
||||||
----------
|
----------
|
||||||
@ -1210,7 +1210,7 @@ SELECT :io_sum_shared_after_reads > :io_sum_shared_before_reads;
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT sum(hits) AS io_sum_shared_before_hits
|
SELECT sum(hits) AS io_sum_shared_before_hits
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
-- Select from the table again to count hits.
|
-- Select from the table again to count hits.
|
||||||
-- Ensure we generate hits by forcing a nested loop self-join with no
|
-- Ensure we generate hits by forcing a nested loop self-join with no
|
||||||
-- materialize node. The outer side's buffer will stay pinned, preventing its
|
-- materialize node. The outer side's buffer will stay pinned, preventing its
|
||||||
@ -1243,7 +1243,7 @@ SELECT pg_stat_force_next_flush();
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT sum(hits) AS io_sum_shared_after_hits
|
SELECT sum(hits) AS io_sum_shared_after_hits
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
SELECT :io_sum_shared_after_hits > :io_sum_shared_before_hits;
|
SELECT :io_sum_shared_after_hits > :io_sum_shared_before_hits;
|
||||||
?column?
|
?column?
|
||||||
----------
|
----------
|
||||||
@ -1264,7 +1264,7 @@ SET temp_buffers TO 100;
|
|||||||
CREATE TEMPORARY TABLE test_io_local(a int, b TEXT);
|
CREATE TEMPORARY TABLE test_io_local(a int, b TEXT);
|
||||||
SELECT sum(extends) AS extends, sum(evictions) AS evictions, sum(writes) AS writes
|
SELECT sum(extends) AS extends, sum(evictions) AS evictions, sum(writes) AS writes
|
||||||
FROM pg_stat_io
|
FROM pg_stat_io
|
||||||
WHERE io_context = 'normal' AND io_object = 'temp relation' \gset io_sum_local_before_
|
WHERE context = 'normal' AND object = 'temp relation' \gset io_sum_local_before_
|
||||||
-- Insert tuples into the temporary table, generating extends in the stats.
|
-- Insert tuples into the temporary table, generating extends in the stats.
|
||||||
-- Insert enough values that we need to reuse and write out dirty local
|
-- Insert enough values that we need to reuse and write out dirty local
|
||||||
-- buffers, generating evictions and writes.
|
-- buffers, generating evictions and writes.
|
||||||
@ -1277,7 +1277,7 @@ SELECT pg_relation_size('test_io_local') / current_setting('block_size')::int8 >
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT sum(reads) AS io_sum_local_before_reads
|
SELECT sum(reads) AS io_sum_local_before_reads
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'temp relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation' \gset
|
||||||
-- Read in evicted buffers, generating reads.
|
-- Read in evicted buffers, generating reads.
|
||||||
SELECT COUNT(*) FROM test_io_local;
|
SELECT COUNT(*) FROM test_io_local;
|
||||||
count
|
count
|
||||||
@ -1296,7 +1296,7 @@ SELECT sum(evictions) AS evictions,
|
|||||||
sum(writes) AS writes,
|
sum(writes) AS writes,
|
||||||
sum(extends) AS extends
|
sum(extends) AS extends
|
||||||
FROM pg_stat_io
|
FROM pg_stat_io
|
||||||
WHERE io_context = 'normal' AND io_object = 'temp relation' \gset io_sum_local_after_
|
WHERE context = 'normal' AND object = 'temp relation' \gset io_sum_local_after_
|
||||||
SELECT :io_sum_local_after_evictions > :io_sum_local_before_evictions,
|
SELECT :io_sum_local_after_evictions > :io_sum_local_before_evictions,
|
||||||
:io_sum_local_after_reads > :io_sum_local_before_reads,
|
:io_sum_local_after_reads > :io_sum_local_before_reads,
|
||||||
:io_sum_local_after_writes > :io_sum_local_before_writes,
|
:io_sum_local_after_writes > :io_sum_local_before_writes,
|
||||||
@ -1317,7 +1317,7 @@ SELECT pg_stat_force_next_flush();
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT sum(writes) AS io_sum_local_new_tblspc_writes
|
SELECT sum(writes) AS io_sum_local_new_tblspc_writes
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'temp relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation' \gset
|
||||||
SELECT :io_sum_local_new_tblspc_writes > :io_sum_local_after_writes;
|
SELECT :io_sum_local_new_tblspc_writes > :io_sum_local_after_writes;
|
||||||
?column?
|
?column?
|
||||||
----------
|
----------
|
||||||
@ -1335,7 +1335,7 @@ RESET temp_buffers;
|
|||||||
-- reads.
|
-- reads.
|
||||||
SET wal_skip_threshold = '1 kB';
|
SET wal_skip_threshold = '1 kB';
|
||||||
SELECT sum(reuses) AS reuses, sum(reads) AS reads
|
SELECT sum(reuses) AS reuses, sum(reads) AS reads
|
||||||
FROM pg_stat_io WHERE io_context = 'vacuum' \gset io_sum_vac_strategy_before_
|
FROM pg_stat_io WHERE context = 'vacuum' \gset io_sum_vac_strategy_before_
|
||||||
CREATE TABLE test_io_vac_strategy(a int, b int) WITH (autovacuum_enabled = 'false');
|
CREATE TABLE test_io_vac_strategy(a int, b int) WITH (autovacuum_enabled = 'false');
|
||||||
INSERT INTO test_io_vac_strategy SELECT i, i from generate_series(1, 8000)i;
|
INSERT INTO test_io_vac_strategy SELECT i, i from generate_series(1, 8000)i;
|
||||||
-- Ensure that the next VACUUM will need to perform IO by rewriting the table
|
-- Ensure that the next VACUUM will need to perform IO by rewriting the table
|
||||||
@ -1349,7 +1349,7 @@ SELECT pg_stat_force_next_flush();
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT sum(reuses) AS reuses, sum(reads) AS reads
|
SELECT sum(reuses) AS reuses, sum(reads) AS reads
|
||||||
FROM pg_stat_io WHERE io_context = 'vacuum' \gset io_sum_vac_strategy_after_
|
FROM pg_stat_io WHERE context = 'vacuum' \gset io_sum_vac_strategy_after_
|
||||||
SELECT :io_sum_vac_strategy_after_reads > :io_sum_vac_strategy_before_reads,
|
SELECT :io_sum_vac_strategy_after_reads > :io_sum_vac_strategy_before_reads,
|
||||||
:io_sum_vac_strategy_after_reuses > :io_sum_vac_strategy_before_reuses;
|
:io_sum_vac_strategy_after_reuses > :io_sum_vac_strategy_before_reuses;
|
||||||
?column? | ?column?
|
?column? | ?column?
|
||||||
@ -1361,7 +1361,7 @@ RESET wal_skip_threshold;
|
|||||||
-- Test that extends done by a CTAS, which uses a BAS_BULKWRITE
|
-- Test that extends done by a CTAS, which uses a BAS_BULKWRITE
|
||||||
-- BufferAccessStrategy, are tracked in pg_stat_io.
|
-- BufferAccessStrategy, are tracked in pg_stat_io.
|
||||||
SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_before
|
SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_before
|
||||||
FROM pg_stat_io WHERE io_context = 'bulkwrite' \gset
|
FROM pg_stat_io WHERE context = 'bulkwrite' \gset
|
||||||
CREATE TABLE test_io_bulkwrite_strategy AS SELECT i FROM generate_series(1,100)i;
|
CREATE TABLE test_io_bulkwrite_strategy AS SELECT i FROM generate_series(1,100)i;
|
||||||
SELECT pg_stat_force_next_flush();
|
SELECT pg_stat_force_next_flush();
|
||||||
pg_stat_force_next_flush
|
pg_stat_force_next_flush
|
||||||
@ -1370,7 +1370,7 @@ SELECT pg_stat_force_next_flush();
|
|||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_after
|
SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_after
|
||||||
FROM pg_stat_io WHERE io_context = 'bulkwrite' \gset
|
FROM pg_stat_io WHERE context = 'bulkwrite' \gset
|
||||||
SELECT :io_sum_bulkwrite_strategy_extends_after > :io_sum_bulkwrite_strategy_extends_before;
|
SELECT :io_sum_bulkwrite_strategy_extends_after > :io_sum_bulkwrite_strategy_extends_before;
|
||||||
?column?
|
?column?
|
||||||
----------
|
----------
|
||||||
|
@ -549,15 +549,15 @@ SELECT pg_stat_get_subscription_stats(NULL);
|
|||||||
-- Create a regular table and insert some data to generate IOCONTEXT_NORMAL
|
-- Create a regular table and insert some data to generate IOCONTEXT_NORMAL
|
||||||
-- extends.
|
-- extends.
|
||||||
SELECT sum(extends) AS io_sum_shared_before_extends
|
SELECT sum(extends) AS io_sum_shared_before_extends
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs
|
SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs
|
||||||
FROM pg_stat_io
|
FROM pg_stat_io
|
||||||
WHERE io_object = 'relation' \gset io_sum_shared_before_
|
WHERE object = 'relation' \gset io_sum_shared_before_
|
||||||
CREATE TABLE test_io_shared(a int);
|
CREATE TABLE test_io_shared(a int);
|
||||||
INSERT INTO test_io_shared SELECT i FROM generate_series(1,100)i;
|
INSERT INTO test_io_shared SELECT i FROM generate_series(1,100)i;
|
||||||
SELECT pg_stat_force_next_flush();
|
SELECT pg_stat_force_next_flush();
|
||||||
SELECT sum(extends) AS io_sum_shared_after_extends
|
SELECT sum(extends) AS io_sum_shared_after_extends
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
SELECT :io_sum_shared_after_extends > :io_sum_shared_before_extends;
|
SELECT :io_sum_shared_after_extends > :io_sum_shared_before_extends;
|
||||||
|
|
||||||
-- After a checkpoint, there should be some additional IOCONTEXT_NORMAL writes
|
-- After a checkpoint, there should be some additional IOCONTEXT_NORMAL writes
|
||||||
@ -567,7 +567,7 @@ CHECKPOINT;
|
|||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs
|
SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs
|
||||||
FROM pg_stat_io
|
FROM pg_stat_io
|
||||||
WHERE io_object = 'relation' \gset io_sum_shared_after_
|
WHERE object = 'relation' \gset io_sum_shared_after_
|
||||||
SELECT :io_sum_shared_after_writes > :io_sum_shared_before_writes;
|
SELECT :io_sum_shared_after_writes > :io_sum_shared_before_writes;
|
||||||
SELECT current_setting('fsync') = 'off'
|
SELECT current_setting('fsync') = 'off'
|
||||||
OR :io_sum_shared_after_fsyncs > :io_sum_shared_before_fsyncs;
|
OR :io_sum_shared_after_fsyncs > :io_sum_shared_before_fsyncs;
|
||||||
@ -575,22 +575,22 @@ SELECT current_setting('fsync') = 'off'
|
|||||||
-- Change the tablespace so that the table is rewritten directly, then SELECT
|
-- Change the tablespace so that the table is rewritten directly, then SELECT
|
||||||
-- from it to cause it to be read back into shared buffers.
|
-- from it to cause it to be read back into shared buffers.
|
||||||
SELECT sum(reads) AS io_sum_shared_before_reads
|
SELECT sum(reads) AS io_sum_shared_before_reads
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
-- Do this in a transaction to prevent spurious failures due to concurrent accesses to our newly
|
-- Do this in a transaction to prevent spurious failures due to concurrent accesses to our newly
|
||||||
-- rewritten table, e.g. by autovacuum.
|
-- rewritten table, e.g. by autovacuum.
|
||||||
BEGIN;
|
BEGIN;
|
||||||
ALTER TABLE test_io_shared SET TABLESPACE regress_tblspace;
|
ALTER TABLE test_io_shared SET TABLESPACE regress_tblspace;
|
||||||
-- SELECT from the table so that the data is read into shared buffers and
|
-- SELECT from the table so that the data is read into shared buffers and
|
||||||
-- io_context 'normal', io_object 'relation' reads are counted.
|
-- context 'normal', object 'relation' reads are counted.
|
||||||
SELECT COUNT(*) FROM test_io_shared;
|
SELECT COUNT(*) FROM test_io_shared;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
SELECT pg_stat_force_next_flush();
|
SELECT pg_stat_force_next_flush();
|
||||||
SELECT sum(reads) AS io_sum_shared_after_reads
|
SELECT sum(reads) AS io_sum_shared_after_reads
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
SELECT :io_sum_shared_after_reads > :io_sum_shared_before_reads;
|
SELECT :io_sum_shared_after_reads > :io_sum_shared_before_reads;
|
||||||
|
|
||||||
SELECT sum(hits) AS io_sum_shared_before_hits
|
SELECT sum(hits) AS io_sum_shared_before_hits
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
-- Select from the table again to count hits.
|
-- Select from the table again to count hits.
|
||||||
-- Ensure we generate hits by forcing a nested loop self-join with no
|
-- Ensure we generate hits by forcing a nested loop self-join with no
|
||||||
-- materialize node. The outer side's buffer will stay pinned, preventing its
|
-- materialize node. The outer side's buffer will stay pinned, preventing its
|
||||||
@ -604,7 +604,7 @@ SELECT COUNT(*) FROM test_io_shared t1 INNER JOIN test_io_shared t2 USING (a);
|
|||||||
COMMIT;
|
COMMIT;
|
||||||
SELECT pg_stat_force_next_flush();
|
SELECT pg_stat_force_next_flush();
|
||||||
SELECT sum(hits) AS io_sum_shared_after_hits
|
SELECT sum(hits) AS io_sum_shared_after_hits
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
|
||||||
SELECT :io_sum_shared_after_hits > :io_sum_shared_before_hits;
|
SELECT :io_sum_shared_after_hits > :io_sum_shared_before_hits;
|
||||||
|
|
||||||
DROP TABLE test_io_shared;
|
DROP TABLE test_io_shared;
|
||||||
@ -623,7 +623,7 @@ SET temp_buffers TO 100;
|
|||||||
CREATE TEMPORARY TABLE test_io_local(a int, b TEXT);
|
CREATE TEMPORARY TABLE test_io_local(a int, b TEXT);
|
||||||
SELECT sum(extends) AS extends, sum(evictions) AS evictions, sum(writes) AS writes
|
SELECT sum(extends) AS extends, sum(evictions) AS evictions, sum(writes) AS writes
|
||||||
FROM pg_stat_io
|
FROM pg_stat_io
|
||||||
WHERE io_context = 'normal' AND io_object = 'temp relation' \gset io_sum_local_before_
|
WHERE context = 'normal' AND object = 'temp relation' \gset io_sum_local_before_
|
||||||
-- Insert tuples into the temporary table, generating extends in the stats.
|
-- Insert tuples into the temporary table, generating extends in the stats.
|
||||||
-- Insert enough values that we need to reuse and write out dirty local
|
-- Insert enough values that we need to reuse and write out dirty local
|
||||||
-- buffers, generating evictions and writes.
|
-- buffers, generating evictions and writes.
|
||||||
@ -632,7 +632,7 @@ INSERT INTO test_io_local SELECT generate_series(1, 5000) as id, repeat('a', 200
|
|||||||
SELECT pg_relation_size('test_io_local') / current_setting('block_size')::int8 > 100;
|
SELECT pg_relation_size('test_io_local') / current_setting('block_size')::int8 > 100;
|
||||||
|
|
||||||
SELECT sum(reads) AS io_sum_local_before_reads
|
SELECT sum(reads) AS io_sum_local_before_reads
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'temp relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation' \gset
|
||||||
-- Read in evicted buffers, generating reads.
|
-- Read in evicted buffers, generating reads.
|
||||||
SELECT COUNT(*) FROM test_io_local;
|
SELECT COUNT(*) FROM test_io_local;
|
||||||
SELECT pg_stat_force_next_flush();
|
SELECT pg_stat_force_next_flush();
|
||||||
@ -641,7 +641,7 @@ SELECT sum(evictions) AS evictions,
|
|||||||
sum(writes) AS writes,
|
sum(writes) AS writes,
|
||||||
sum(extends) AS extends
|
sum(extends) AS extends
|
||||||
FROM pg_stat_io
|
FROM pg_stat_io
|
||||||
WHERE io_context = 'normal' AND io_object = 'temp relation' \gset io_sum_local_after_
|
WHERE context = 'normal' AND object = 'temp relation' \gset io_sum_local_after_
|
||||||
SELECT :io_sum_local_after_evictions > :io_sum_local_before_evictions,
|
SELECT :io_sum_local_after_evictions > :io_sum_local_before_evictions,
|
||||||
:io_sum_local_after_reads > :io_sum_local_before_reads,
|
:io_sum_local_after_reads > :io_sum_local_before_reads,
|
||||||
:io_sum_local_after_writes > :io_sum_local_before_writes,
|
:io_sum_local_after_writes > :io_sum_local_before_writes,
|
||||||
@ -653,7 +653,7 @@ SELECT :io_sum_local_after_evictions > :io_sum_local_before_evictions,
|
|||||||
ALTER TABLE test_io_local SET TABLESPACE regress_tblspace;
|
ALTER TABLE test_io_local SET TABLESPACE regress_tblspace;
|
||||||
SELECT pg_stat_force_next_flush();
|
SELECT pg_stat_force_next_flush();
|
||||||
SELECT sum(writes) AS io_sum_local_new_tblspc_writes
|
SELECT sum(writes) AS io_sum_local_new_tblspc_writes
|
||||||
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'temp relation' \gset
|
FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation' \gset
|
||||||
SELECT :io_sum_local_new_tblspc_writes > :io_sum_local_after_writes;
|
SELECT :io_sum_local_new_tblspc_writes > :io_sum_local_after_writes;
|
||||||
RESET temp_buffers;
|
RESET temp_buffers;
|
||||||
|
|
||||||
@ -668,7 +668,7 @@ RESET temp_buffers;
|
|||||||
-- reads.
|
-- reads.
|
||||||
SET wal_skip_threshold = '1 kB';
|
SET wal_skip_threshold = '1 kB';
|
||||||
SELECT sum(reuses) AS reuses, sum(reads) AS reads
|
SELECT sum(reuses) AS reuses, sum(reads) AS reads
|
||||||
FROM pg_stat_io WHERE io_context = 'vacuum' \gset io_sum_vac_strategy_before_
|
FROM pg_stat_io WHERE context = 'vacuum' \gset io_sum_vac_strategy_before_
|
||||||
CREATE TABLE test_io_vac_strategy(a int, b int) WITH (autovacuum_enabled = 'false');
|
CREATE TABLE test_io_vac_strategy(a int, b int) WITH (autovacuum_enabled = 'false');
|
||||||
INSERT INTO test_io_vac_strategy SELECT i, i from generate_series(1, 8000)i;
|
INSERT INTO test_io_vac_strategy SELECT i, i from generate_series(1, 8000)i;
|
||||||
-- Ensure that the next VACUUM will need to perform IO by rewriting the table
|
-- Ensure that the next VACUUM will need to perform IO by rewriting the table
|
||||||
@ -677,7 +677,7 @@ VACUUM (FULL) test_io_vac_strategy;
|
|||||||
VACUUM (PARALLEL 0) test_io_vac_strategy;
|
VACUUM (PARALLEL 0) test_io_vac_strategy;
|
||||||
SELECT pg_stat_force_next_flush();
|
SELECT pg_stat_force_next_flush();
|
||||||
SELECT sum(reuses) AS reuses, sum(reads) AS reads
|
SELECT sum(reuses) AS reuses, sum(reads) AS reads
|
||||||
FROM pg_stat_io WHERE io_context = 'vacuum' \gset io_sum_vac_strategy_after_
|
FROM pg_stat_io WHERE context = 'vacuum' \gset io_sum_vac_strategy_after_
|
||||||
SELECT :io_sum_vac_strategy_after_reads > :io_sum_vac_strategy_before_reads,
|
SELECT :io_sum_vac_strategy_after_reads > :io_sum_vac_strategy_before_reads,
|
||||||
:io_sum_vac_strategy_after_reuses > :io_sum_vac_strategy_before_reuses;
|
:io_sum_vac_strategy_after_reuses > :io_sum_vac_strategy_before_reuses;
|
||||||
RESET wal_skip_threshold;
|
RESET wal_skip_threshold;
|
||||||
@ -685,11 +685,11 @@ RESET wal_skip_threshold;
|
|||||||
-- Test that extends done by a CTAS, which uses a BAS_BULKWRITE
|
-- Test that extends done by a CTAS, which uses a BAS_BULKWRITE
|
||||||
-- BufferAccessStrategy, are tracked in pg_stat_io.
|
-- BufferAccessStrategy, are tracked in pg_stat_io.
|
||||||
SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_before
|
SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_before
|
||||||
FROM pg_stat_io WHERE io_context = 'bulkwrite' \gset
|
FROM pg_stat_io WHERE context = 'bulkwrite' \gset
|
||||||
CREATE TABLE test_io_bulkwrite_strategy AS SELECT i FROM generate_series(1,100)i;
|
CREATE TABLE test_io_bulkwrite_strategy AS SELECT i FROM generate_series(1,100)i;
|
||||||
SELECT pg_stat_force_next_flush();
|
SELECT pg_stat_force_next_flush();
|
||||||
SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_after
|
SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_after
|
||||||
FROM pg_stat_io WHERE io_context = 'bulkwrite' \gset
|
FROM pg_stat_io WHERE context = 'bulkwrite' \gset
|
||||||
SELECT :io_sum_bulkwrite_strategy_extends_after > :io_sum_bulkwrite_strategy_extends_before;
|
SELECT :io_sum_bulkwrite_strategy_extends_after > :io_sum_bulkwrite_strategy_extends_before;
|
||||||
|
|
||||||
-- Test IO stats reset
|
-- Test IO stats reset
|
||||||
|
Loading…
x
Reference in New Issue
Block a user