aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Korotkov <akorotkov@postgresql.org>2020-04-28 11:07:56 +0300
committerAlexander Korotkov <akorotkov@postgresql.org>2020-04-28 11:30:33 +0300
commitef11051bbe96ea2d06583e4b3b9daaa02657dd42 (patch)
tree94b4022bd3a6766d6897b34d51113624c790cfd0
parentebf6de8692766177a36e7f5fb7545a52a0d5d881 (diff)
downloadpostgresql-ef11051bbe96ea2d06583e4b3b9daaa02657dd42.tar.gz
postgresql-ef11051bbe96ea2d06583e4b3b9daaa02657dd42.zip
Fix definition of pg_statio_all_tables view
pg_statio_all_tables view appears to have a wrong grouping. As the result numbers of toast index blocks read and hit were multiplied to the number of table indexes. This commit fixes the view definition. Backpatching this appears difficult. We don't have a mechanism to patch a system catalog of existing instances in minor upgrade. We can write a release notes instruction to do this manually. But per discussion this is probably not so critical bug for doing such an intrusive fix. Reported-by: Andrei Zubkov Discussion: https://postgr.es/m/CAPpHfdtMYkkNudLMG9G0dxX_B%3Dn5sfKzOyxxrvWYtSicaGW0Lw%40mail.gmail.com
-rw-r--r--src/backend/catalog/system_views.sql8
-rw-r--r--src/test/regress/expected/rules.out6
2 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index d406ea8118c..2bd5f5ea14a 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -642,16 +642,16 @@ CREATE VIEW pg_statio_all_tables AS
pg_stat_get_blocks_fetched(T.oid) -
pg_stat_get_blocks_hit(T.oid) AS toast_blks_read,
pg_stat_get_blocks_hit(T.oid) AS toast_blks_hit,
- sum(pg_stat_get_blocks_fetched(X.indexrelid) -
- pg_stat_get_blocks_hit(X.indexrelid))::bigint AS tidx_blks_read,
- sum(pg_stat_get_blocks_hit(X.indexrelid))::bigint AS tidx_blks_hit
+ pg_stat_get_blocks_fetched(X.indexrelid) -
+ pg_stat_get_blocks_hit(X.indexrelid) AS tidx_blks_read,
+ pg_stat_get_blocks_hit(X.indexrelid) AS tidx_blks_hit
FROM pg_class C LEFT JOIN
pg_index I ON C.oid = I.indrelid LEFT JOIN
pg_class T ON C.reltoastrelid = T.oid LEFT JOIN
pg_index X ON T.oid = X.indrelid
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE C.relkind IN ('r', 't', 'm')
- GROUP BY C.oid, N.nspname, C.relname, T.oid, X.indrelid;
+ GROUP BY C.oid, N.nspname, C.relname, T.oid, X.indexrelid;
CREATE VIEW pg_statio_sys_tables AS
SELECT * FROM pg_statio_all_tables
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index ac31840739d..8876025aaa7 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -2216,15 +2216,15 @@ pg_statio_all_tables| SELECT c.oid AS relid,
(sum(pg_stat_get_blocks_hit(i.indexrelid)))::bigint AS idx_blks_hit,
(pg_stat_get_blocks_fetched(t.oid) - pg_stat_get_blocks_hit(t.oid)) AS toast_blks_read,
pg_stat_get_blocks_hit(t.oid) AS toast_blks_hit,
- (sum((pg_stat_get_blocks_fetched(x.indexrelid) - pg_stat_get_blocks_hit(x.indexrelid))))::bigint AS tidx_blks_read,
- (sum(pg_stat_get_blocks_hit(x.indexrelid)))::bigint AS tidx_blks_hit
+ (pg_stat_get_blocks_fetched(x.indexrelid) - pg_stat_get_blocks_hit(x.indexrelid)) AS tidx_blks_read,
+ pg_stat_get_blocks_hit(x.indexrelid) AS tidx_blks_hit
FROM ((((pg_class c
LEFT JOIN pg_index i ON ((c.oid = i.indrelid)))
LEFT JOIN pg_class t ON ((c.reltoastrelid = t.oid)))
LEFT JOIN pg_index x ON ((t.oid = x.indrelid)))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char", 'm'::"char"]))
- GROUP BY c.oid, n.nspname, c.relname, t.oid, x.indrelid;
+ GROUP BY c.oid, n.nspname, c.relname, t.oid, x.indexrelid;
pg_statio_sys_indexes| SELECT pg_statio_all_indexes.relid,
pg_statio_all_indexes.indexrelid,
pg_statio_all_indexes.schemaname,