diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2021-08-28 15:58:23 -0400 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2021-08-28 15:58:23 -0400 |
commit | 375aed36ad83f0e021e9bdd3a0034c0c992c66dc (patch) | |
tree | 90d5fa4c65ee034827ad7b3ac87c26214dfffd1f /src/backend/postmaster/pgstat.c | |
parent | 1f092a309eeecd097938bacc201c779574ced3b6 (diff) |
Keep stats up to date for partitioned tables
In the long-going saga for analyze on partitioned tables, one thing I
missed while reverting 0827e8af70f4 is the maintenance of analyze count
and last analyze time for partitioned tables. This is a mostly trivial
change that enables users assess the need for invoking manual ANALYZE on
partitioned tables.
This patch, posted by Justin and modified a bit by me (Álvaro), can be
mostly traced back to Hosoya-san, though any problems introduced with
the scissors are mine.
Backpatch to 14, in line with 6f8127b73901.
Co-authored-by: Yuzuko Hosoya <yuzukohosoya@gmail.com>
Co-authored-by: Justin Pryzby <pryzby@telsasoft.com>
Co-authored-by: Álvaro Herrera <alvherre@alvh.no-ip.org>
Reported-by: Justin Pryzby <pryzby@telsasoft.com>
Discussion: https://postgr.es/m/20210816222810.GE10479@telsasoft.com
Diffstat (limited to 'src/backend/postmaster/pgstat.c')
-rw-r--r-- | src/backend/postmaster/pgstat.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index a3c35bdf609..4a280897b19 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -1632,8 +1632,11 @@ pgstat_report_analyze(Relation rel, * be double-counted after commit. (This approach also ensures that the * collector ends up with the right numbers if we abort instead of * committing.) + * + * Waste no time on partitioned tables, though. */ - if (rel->pgstat_info != NULL) + if (rel->pgstat_info != NULL && + rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE) { PgStat_TableXactStatus *trans; @@ -1997,8 +2000,10 @@ pgstat_initstats(Relation rel) Oid rel_id = rel->rd_id; char relkind = rel->rd_rel->relkind; - /* We only count stats for things that have storage */ - if (!RELKIND_HAS_STORAGE(relkind)) + /* + * We only count stats for relations with storage and partitioned tables + */ + if (!RELKIND_HAS_STORAGE(relkind) && relkind != RELKIND_PARTITIONED_TABLE) { rel->pgstat_info = NULL; return; |