digoal
2023-03-31
PostgreSQL , PolarDB , hits , pg_stat_io
PostgreSQL pg_stat_io 增加 hits, Track shared buffer hits . 用于统计每种backend process在shared buffer中命中block的次数.
pg_stat_io
- One row for each combination of backend type, context, and target object containing cluster-wide I/O statistics.
pg_stat_io.hits
- The number of times a desired block was found in a shared buffer.
Track shared buffer hits in pg_stat_io
author Andres Freund <andres@anarazel.de>
Fri, 31 Mar 2023 02:22:40 +0000 (19:22 -0700)
committer Andres Freund <andres@anarazel.de>
Fri, 31 Mar 2023 02:24:21 +0000 (19:24 -0700)
commit 8aaa04b32d790da595684de58ae4fc2db96becff
tree d9993491ee35f81fbf8be407a4ef76b486768ef0 tree
parent 6c3b697b19db6274da622cf0fe7a7ad32eeeced3 commit | diff
Track shared buffer hits in pg_stat_io
Among other things, this should make it easier to calculate a useful cache hit
ratio by excluding buffer reads via buffer access strategies. As buffer access
strategies reuse buffers (and thus evict the prior buffer contents), it is
normal to see reads on repeated scans of the same data.
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAAKRu_beMa9Hzih40%3DXPYqhDVz6tsgUGTrhZXRo%3Dunp%2Bszb%3DUA%40mail.gmail.com
1122 CREATE VIEW pg_stat_io AS
1123 SELECT
1124 b.backend_type,
1125 b.io_object,
1126 b.io_context,
1127 b.reads,
1128 b.writes,
1129 b.extends,
1130 b.op_bytes,
1131 b.hits,
1132 b.evictions,
1133 b.reuses,
1134 b.fsyncs,
1135 b.stats_reset
1136 FROM pg_stat_get_io() b;
982 <structfield>backend_type</structfield> <type>text</type>
983 </para>
984 <para>
985 Type of current backend. Possible types are
986 <literal>autovacuum launcher</literal>,
<literal>autovacuum worker</literal>,
987 <literal>logical replication launcher</literal>,
988 <literal>logical replication worker</literal>,
989 <literal>parallel worker</literal>,
<literal>background writer</literal>,
990 <literal>client backend</literal>,
<literal>checkpointer</literal>,
991 <literal>archiver</literal>,
992 <literal>startup</literal>,
<literal>walreceiver</literal>,
993 <literal>walsender</literal> and
<literal>walwriter</literal>.
994 In addition, background workers registered by extensions may have
995 additional types.