Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0ecb87e

Browse files
committed
Remove io prefix from pg_stat_io columns
a9c70b4 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
1 parent eab2d31 commit 0ecb87e

File tree

10 files changed

+60
-60
lines changed

10 files changed

+60
-60
lines changed

contrib/amcheck/expected/check_heap.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ INSERT INTO heaptest (a, b)
8080
SET allow_in_place_tablespaces = true;
8181
CREATE TABLESPACE regress_test_stats_tblspc LOCATION '';
8282
SELECT sum(reads) AS stats_bulkreads_before
83-
FROM pg_stat_io WHERE io_context = 'bulkread' \gset
83+
FROM pg_stat_io WHERE context = 'bulkread' \gset
8484
ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc;
8585
-- Check that valid options are not rejected nor corruption reported
8686
-- for a non-empty table
@@ -114,7 +114,7 @@ SELECT pg_stat_force_next_flush();
114114
(1 row)
115115

116116
SELECT sum(reads) AS stats_bulkreads_after
117-
FROM pg_stat_io WHERE io_context = 'bulkread' \gset
117+
FROM pg_stat_io WHERE context = 'bulkread' \gset
118118
SELECT :stats_bulkreads_after > :stats_bulkreads_before;
119119
?column?
120120
----------

contrib/amcheck/sql/check_heap.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ INSERT INTO heaptest (a, b)
4040
SET allow_in_place_tablespaces = true;
4141
CREATE TABLESPACE regress_test_stats_tblspc LOCATION '';
4242
SELECT sum(reads) AS stats_bulkreads_before
43-
FROM pg_stat_io WHERE io_context = 'bulkread' \gset
43+
FROM pg_stat_io WHERE context = 'bulkread' \gset
4444
ALTER TABLE heaptest SET TABLESPACE regress_test_stats_tblspc;
4545

4646
-- Check that valid options are not rejected nor corruption reported
@@ -55,7 +55,7 @@ SELECT * FROM verify_heapam(relation := 'heaptest', startblock := 0, endblock :=
5555
-- causing an additional bulkread, which should be reflected in pg_stat_io.
5656
SELECT pg_stat_force_next_flush();
5757
SELECT sum(reads) AS stats_bulkreads_after
58-
FROM pg_stat_io WHERE io_context = 'bulkread' \gset
58+
FROM pg_stat_io WHERE context = 'bulkread' \gset
5959
SELECT :stats_bulkreads_after > :stats_bulkreads_before;
6060

6161
CREATE ROLE regress_heaptest_role;

doc/src/sgml/monitoring.sgml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,7 +3754,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
37543754
<row>
37553755
<entry role="catalog_table_entry">
37563756
<para role="column_definition">
3757-
<structfield>io_object</structfield> <type>text</type>
3757+
<structfield>object</structfield> <type>text</type>
37583758
</para>
37593759
<para>
37603760
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
37773777
<row>
37783778
<entry role="catalog_table_entry">
37793779
<para role="column_definition">
3780-
<structfield>io_context</structfield> <type>text</type>
3780+
<structfield>context</structfield> <type>text</type>
37813781
</para>
37823782
<para>
37833783
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
37863786
<listitem>
37873787
<para>
37883788
<literal>normal</literal>: The default or standard
3789-
<varname>io_context</varname> for a type of I/O operation. For
3789+
<varname>context</varname> for a type of I/O operation. For
37903790
example, by default, relation data is read into and written out from
37913791
shared buffers. Thus, reads and writes of relation data to and from
3792-
shared buffers are tracked in <varname>io_context</varname>
3792+
shared buffers are tracked in <varname>context</varname>
37933793
<literal>normal</literal>.
37943794
</para>
37953795
</listitem>
@@ -3798,7 +3798,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
37983798
<literal>vacuum</literal>: I/O operations performed outside of shared
37993799
buffers while vacuuming and analyzing permanent relations. Temporary
38003800
table vacuums use the same local buffer pool as other temporary table
3801-
IO operations and are tracked in <varname>io_context</varname>
3801+
IO operations and are tracked in <varname>context</varname>
38023802
<literal>normal</literal>.
38033803
</para>
38043804
</listitem>
@@ -3929,9 +3929,9 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
39293929
buffer in order to make it available for another use.
39303930
</para>
39313931
<para>
3932-
In <varname>io_context</varname> <literal>normal</literal>, this counts
3932+
In <varname>context</varname> <literal>normal</literal>, this counts
39333933
the number of times a block was evicted from a buffer and replaced with
3934-
another block. In <varname>io_context</varname>s
3934+
another block. In <varname>context</varname>s
39353935
<literal>bulkwrite</literal>, <literal>bulkread</literal>, and
39363936
<literal>vacuum</literal>, this counts the number of times a block was
39373937
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
39493949
The number of times an existing buffer in a size-limited ring buffer
39503950
outside of shared buffers was reused as part of an I/O operation in the
39513951
<literal>bulkread</literal>, <literal>bulkwrite</literal>, or
3952-
<literal>vacuum</literal> <varname>io_context</varname>s.
3952+
<literal>vacuum</literal> <varname>context</varname>s.
39533953
</para>
39543954
</entry>
39553955
</row>
@@ -3961,7 +3961,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
39613961
</para>
39623962
<para>
39633963
Number of <literal>fsync</literal> calls. These are only tracked in
3964-
<varname>io_context</varname> <literal>normal</literal>.
3964+
<varname>context</varname> <literal>normal</literal>.
39653965
</para>
39663966
</entry>
39673967
</row>
@@ -3997,15 +3997,15 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
39973997
in some I/O contexts. These rows are omitted from the view. For example, the
39983998
checkpointer does not checkpoint temporary tables, so there will be no rows
39993999
for <varname>backend_type</varname> <literal>checkpointer</literal> and
4000-
<varname>io_object</varname> <literal>temp relation</literal>.
4000+
<varname>object</varname> <literal>temp relation</literal>.
40014001
</para>
40024002

40034003
<para>
40044004
In addition, some I/O operations will never be performed either by certain
40054005
backend types or on certain I/O objects and/or in certain I/O contexts.
40064006
These cells will be NULL. For example, temporary tables are not
40074007
<literal>fsync</literal>ed, so <varname>fsyncs</varname> will be NULL for
4008-
<varname>io_object</varname> <literal>temp relation</literal>. Also, the
4008+
<varname>object</varname> <literal>temp relation</literal>. Also, the
40094009
background writer does not perform reads, so <varname>reads</varname> will
40104010
be NULL in rows for <varname>backend_type</varname> <literal>background
40114011
writer</literal>.

src/backend/catalog/system_views.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,8 @@ CREATE VIEW pg_stat_bgwriter AS
11251125
CREATE VIEW pg_stat_io AS
11261126
SELECT
11271127
b.backend_type,
1128-
b.io_object,
1129-
b.io_context,
1128+
b.object,
1129+
b.context,
11301130
b.reads,
11311131
b.read_time,
11321132
b.writes,

src/backend/utils/adt/pgstatfuncs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,8 @@ typedef enum io_stat_col
12621262
{
12631263
IO_COL_INVALID = -1,
12641264
IO_COL_BACKEND_TYPE,
1265-
IO_COL_IO_OBJECT,
1266-
IO_COL_IO_CONTEXT,
1265+
IO_COL_OBJECT,
1266+
IO_COL_CONTEXT,
12671267
IO_COL_READS,
12681268
IO_COL_READ_TIME,
12691269
IO_COL_WRITES,
@@ -1394,8 +1394,8 @@ pg_stat_get_io(PG_FUNCTION_ARGS)
13941394
continue;
13951395

13961396
values[IO_COL_BACKEND_TYPE] = bktype_desc;
1397-
values[IO_COL_IO_CONTEXT] = CStringGetTextDatum(context_name);
1398-
values[IO_COL_IO_OBJECT] = CStringGetTextDatum(obj_name);
1397+
values[IO_COL_CONTEXT] = CStringGetTextDatum(context_name);
1398+
values[IO_COL_OBJECT] = CStringGetTextDatum(obj_name);
13991399
values[IO_COL_RESET_TIME] = TimestampTzGetDatum(reset_time);
14001400

14011401
/*

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/* yyyymmddN */
60-
#define CATALOG_VERSION_NO 202304111
60+
#define CATALOG_VERSION_NO 202304211
6161

6262
#endif

src/include/catalog/pg_proc.dat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5762,7 +5762,7 @@
57625762
proparallel => 'r', prorettype => 'record', proargtypes => '',
57635763
proallargtypes => '{text,text,text,int8,float8,int8,float8,int8,float8,int8,int8,int8,int8,int8,float8,timestamptz}',
57645764
proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
5765-
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}',
5765+
proargnames => '{backend_type,object,context,reads,read_time,writes,write_time,extends,extend_time,op_bytes,hits,evictions,reuses,fsyncs,fsync_time,stats_reset}',
57665766
prosrc => 'pg_stat_get_io' },
57675767

57685768
{ oid => '1136', descr => 'statistics: information about WAL activity',

src/test/regress/expected/rules.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,8 +1881,8 @@ pg_stat_gssapi| SELECT pid,
18811881
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)
18821882
WHERE (client_port IS NOT NULL);
18831883
pg_stat_io| SELECT backend_type,
1884-
io_object,
1885-
io_context,
1884+
object,
1885+
context,
18861886
reads,
18871887
read_time,
18881888
writes,
@@ -1896,7 +1896,7 @@ pg_stat_io| SELECT backend_type,
18961896
fsyncs,
18971897
fsync_time,
18981898
stats_reset
1899-
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);
1899+
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);
19001900
pg_stat_progress_analyze| SELECT s.pid,
19011901
s.datid,
19021902
d.datname,

src/test/regress/expected/stats.out

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,10 +1137,10 @@ SELECT pg_stat_get_subscription_stats(NULL);
11371137
-- Create a regular table and insert some data to generate IOCONTEXT_NORMAL
11381138
-- extends.
11391139
SELECT sum(extends) AS io_sum_shared_before_extends
1140-
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
1140+
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
11411141
SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs
11421142
FROM pg_stat_io
1143-
WHERE io_object = 'relation' \gset io_sum_shared_before_
1143+
WHERE object = 'relation' \gset io_sum_shared_before_
11441144
CREATE TABLE test_io_shared(a int);
11451145
INSERT INTO test_io_shared SELECT i FROM generate_series(1,100)i;
11461146
SELECT pg_stat_force_next_flush();
@@ -1150,7 +1150,7 @@ SELECT pg_stat_force_next_flush();
11501150
(1 row)
11511151

11521152
SELECT sum(extends) AS io_sum_shared_after_extends
1153-
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
1153+
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
11541154
SELECT :io_sum_shared_after_extends > :io_sum_shared_before_extends;
11551155
?column?
11561156
----------
@@ -1164,7 +1164,7 @@ CHECKPOINT;
11641164
CHECKPOINT;
11651165
SELECT sum(writes) AS writes, sum(fsyncs) AS fsyncs
11661166
FROM pg_stat_io
1167-
WHERE io_object = 'relation' \gset io_sum_shared_after_
1167+
WHERE object = 'relation' \gset io_sum_shared_after_
11681168
SELECT :io_sum_shared_after_writes > :io_sum_shared_before_writes;
11691169
?column?
11701170
----------
@@ -1181,13 +1181,13 @@ SELECT current_setting('fsync') = 'off'
11811181
-- Change the tablespace so that the table is rewritten directly, then SELECT
11821182
-- from it to cause it to be read back into shared buffers.
11831183
SELECT sum(reads) AS io_sum_shared_before_reads
1184-
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
1184+
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
11851185
-- Do this in a transaction to prevent spurious failures due to concurrent accesses to our newly
11861186
-- rewritten table, e.g. by autovacuum.
11871187
BEGIN;
11881188
ALTER TABLE test_io_shared SET TABLESPACE regress_tblspace;
11891189
-- SELECT from the table so that the data is read into shared buffers and
1190-
-- io_context 'normal', io_object 'relation' reads are counted.
1190+
-- context 'normal', object 'relation' reads are counted.
11911191
SELECT COUNT(*) FROM test_io_shared;
11921192
count
11931193
-------
@@ -1202,15 +1202,15 @@ SELECT pg_stat_force_next_flush();
12021202
(1 row)
12031203

12041204
SELECT sum(reads) AS io_sum_shared_after_reads
1205-
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
1205+
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
12061206
SELECT :io_sum_shared_after_reads > :io_sum_shared_before_reads;
12071207
?column?
12081208
----------
12091209
t
12101210
(1 row)
12111211

12121212
SELECT sum(hits) AS io_sum_shared_before_hits
1213-
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
1213+
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
12141214
-- Select from the table again to count hits.
12151215
-- Ensure we generate hits by forcing a nested loop self-join with no
12161216
-- materialize node. The outer side's buffer will stay pinned, preventing its
@@ -1243,7 +1243,7 @@ SELECT pg_stat_force_next_flush();
12431243
(1 row)
12441244

12451245
SELECT sum(hits) AS io_sum_shared_after_hits
1246-
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'relation' \gset
1246+
FROM pg_stat_io WHERE context = 'normal' AND object = 'relation' \gset
12471247
SELECT :io_sum_shared_after_hits > :io_sum_shared_before_hits;
12481248
?column?
12491249
----------
@@ -1264,7 +1264,7 @@ SET temp_buffers TO 100;
12641264
CREATE TEMPORARY TABLE test_io_local(a int, b TEXT);
12651265
SELECT sum(extends) AS extends, sum(evictions) AS evictions, sum(writes) AS writes
12661266
FROM pg_stat_io
1267-
WHERE io_context = 'normal' AND io_object = 'temp relation' \gset io_sum_local_before_
1267+
WHERE context = 'normal' AND object = 'temp relation' \gset io_sum_local_before_
12681268
-- Insert tuples into the temporary table, generating extends in the stats.
12691269
-- Insert enough values that we need to reuse and write out dirty local
12701270
-- buffers, generating evictions and writes.
@@ -1277,7 +1277,7 @@ SELECT pg_relation_size('test_io_local') / current_setting('block_size')::int8 >
12771277
(1 row)
12781278

12791279
SELECT sum(reads) AS io_sum_local_before_reads
1280-
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'temp relation' \gset
1280+
FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation' \gset
12811281
-- Read in evicted buffers, generating reads.
12821282
SELECT COUNT(*) FROM test_io_local;
12831283
count
@@ -1296,7 +1296,7 @@ SELECT sum(evictions) AS evictions,
12961296
sum(writes) AS writes,
12971297
sum(extends) AS extends
12981298
FROM pg_stat_io
1299-
WHERE io_context = 'normal' AND io_object = 'temp relation' \gset io_sum_local_after_
1299+
WHERE context = 'normal' AND object = 'temp relation' \gset io_sum_local_after_
13001300
SELECT :io_sum_local_after_evictions > :io_sum_local_before_evictions,
13011301
:io_sum_local_after_reads > :io_sum_local_before_reads,
13021302
:io_sum_local_after_writes > :io_sum_local_before_writes,
@@ -1317,7 +1317,7 @@ SELECT pg_stat_force_next_flush();
13171317
(1 row)
13181318

13191319
SELECT sum(writes) AS io_sum_local_new_tblspc_writes
1320-
FROM pg_stat_io WHERE io_context = 'normal' AND io_object = 'temp relation' \gset
1320+
FROM pg_stat_io WHERE context = 'normal' AND object = 'temp relation' \gset
13211321
SELECT :io_sum_local_new_tblspc_writes > :io_sum_local_after_writes;
13221322
?column?
13231323
----------
@@ -1335,7 +1335,7 @@ RESET temp_buffers;
13351335
-- reads.
13361336
SET wal_skip_threshold = '1 kB';
13371337
SELECT sum(reuses) AS reuses, sum(reads) AS reads
1338-
FROM pg_stat_io WHERE io_context = 'vacuum' \gset io_sum_vac_strategy_before_
1338+
FROM pg_stat_io WHERE context = 'vacuum' \gset io_sum_vac_strategy_before_
13391339
CREATE TABLE test_io_vac_strategy(a int, b int) WITH (autovacuum_enabled = 'false');
13401340
INSERT INTO test_io_vac_strategy SELECT i, i from generate_series(1, 8000)i;
13411341
-- Ensure that the next VACUUM will need to perform IO by rewriting the table
@@ -1349,7 +1349,7 @@ SELECT pg_stat_force_next_flush();
13491349
(1 row)
13501350

13511351
SELECT sum(reuses) AS reuses, sum(reads) AS reads
1352-
FROM pg_stat_io WHERE io_context = 'vacuum' \gset io_sum_vac_strategy_after_
1352+
FROM pg_stat_io WHERE context = 'vacuum' \gset io_sum_vac_strategy_after_
13531353
SELECT :io_sum_vac_strategy_after_reads > :io_sum_vac_strategy_before_reads,
13541354
:io_sum_vac_strategy_after_reuses > :io_sum_vac_strategy_before_reuses;
13551355
?column? | ?column?
@@ -1361,7 +1361,7 @@ RESET wal_skip_threshold;
13611361
-- Test that extends done by a CTAS, which uses a BAS_BULKWRITE
13621362
-- BufferAccessStrategy, are tracked in pg_stat_io.
13631363
SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_before
1364-
FROM pg_stat_io WHERE io_context = 'bulkwrite' \gset
1364+
FROM pg_stat_io WHERE context = 'bulkwrite' \gset
13651365
CREATE TABLE test_io_bulkwrite_strategy AS SELECT i FROM generate_series(1,100)i;
13661366
SELECT pg_stat_force_next_flush();
13671367
pg_stat_force_next_flush
@@ -1370,7 +1370,7 @@ SELECT pg_stat_force_next_flush();
13701370
(1 row)
13711371

13721372
SELECT sum(extends) AS io_sum_bulkwrite_strategy_extends_after
1373-
FROM pg_stat_io WHERE io_context = 'bulkwrite' \gset
1373+
FROM pg_stat_io WHERE context = 'bulkwrite' \gset
13741374
SELECT :io_sum_bulkwrite_strategy_extends_after > :io_sum_bulkwrite_strategy_extends_before;
13751375
?column?
13761376
----------

0 commit comments

Comments
 (0)