diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2021-08-16 17:27:52 -0400 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2021-08-16 17:27:52 -0400 |
commit | b3d24cc0f0aa882ceec0a74a99f94166c6fc3247 (patch) | |
tree | 0731f8b22bc7c5be494560d1af3d7f432434d7c4 /src/backend/commands/tablecmds.c | |
parent | f83d80ea1e57927471848d901843ddc6fd5ecacc (diff) |
Revert analyze support for partitioned tables
This reverts the following commits:
1b5617eb844cd2470a334c1d2eec66cf9b39c41a Describe (auto-)analyze behavior for partitioned tables
0e69f705cc1a3df273b38c9883fb5765991e04fe Set pg_class.reltuples for partitioned tables
41badeaba8beee7648ebe7923a41c04f1f3cb302 Document ANALYZE storage parameters for partitioned tables
0827e8af70f4653ba17ed773f123a60eadd9f9c9 autovacuum: handle analyze for partitioned tables
There are efficiency issues in this code when handling databases with
large numbers of partitions, and it doesn't look like there isn't any
trivial way to handle those. There are some other issues as well. It's
now too late in the cycle for nontrivial fixes, so we'll have to let
Postgres 14 users continue to manually deal with ANALYZE their
partitioned tables, and hopefully we can fix the issues for Postgres 15.
I kept [most of] be280cdad298 ("Don't reset relhasindex for partitioned
tables on ANALYZE") because while we added it due to 0827e8af70f4, it is
a good bugfix in its own right, since it affects manual analyze as well
as autovacuum-induced analyze, and there's no reason to revert it.
I retained the addition of relkind 'p' to tables included by
pg_stat_user_tables, because reverting that would require a catversion
bump.
Also, in pg14 only, I keep a struct member that was added to
PgStat_TabStatEntry to avoid breaking compatibility with existing stat
files.
Backpatch to 14.
Discussion: https://postgr.es/m/20210722205458.f2bug3z6qzxzpx2s@alap3.anarazel.de
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 6dae7e99ace..bd3e701ca3a 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -335,7 +335,6 @@ typedef struct ForeignTruncateInfo static void truncate_check_rel(Oid relid, Form_pg_class reltuple); static void truncate_check_perms(Oid relid, Form_pg_class reltuple); static void truncate_check_activity(Relation rel); -static void truncate_update_partedrel_stats(List *parted_rels); static void RangeVarCallbackForTruncate(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg); static List *MergeAttributes(List *schema, List *supers, char relpersistence, @@ -1739,7 +1738,6 @@ ExecuteTruncateGuts(List *explicit_rels, { List *rels; List *seq_relids = NIL; - List *parted_rels = NIL; HTAB *ft_htab = NULL; EState *estate; ResultRelInfo *resultRelInfos; @@ -1888,15 +1886,9 @@ ExecuteTruncateGuts(List *explicit_rels, { Relation rel = (Relation) lfirst(cell); - /* - * Save OID of partitioned tables for later; nothing else to do for - * them here. - */ + /* Skip partitioned tables as there is nothing to do */ if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE) - { - parted_rels = lappend_oid(parted_rels, RelationGetRelid(rel)); continue; - } /* * Build the lists of foreign tables belonging to each foreign server @@ -2044,9 +2036,6 @@ ExecuteTruncateGuts(List *explicit_rels, ResetSequence(seq_relid); } - /* Reset partitioned tables' pg_class.reltuples */ - truncate_update_partedrel_stats(parted_rels); - /* * Write a WAL record to allow this set of actions to be logically * decoded. @@ -2194,40 +2183,6 @@ truncate_check_activity(Relation rel) } /* - * Update pg_class.reltuples for all the given partitioned tables to 0. - */ -static void -truncate_update_partedrel_stats(List *parted_rels) -{ - Relation pg_class; - ListCell *lc; - - pg_class = table_open(RelationRelationId, RowExclusiveLock); - - foreach(lc, parted_rels) - { - Oid relid = lfirst_oid(lc); - HeapTuple tuple; - Form_pg_class rd_rel; - - tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid)); - if (!HeapTupleIsValid(tuple)) - elog(ERROR, "could not find tuple for relation %u", relid); - rd_rel = (Form_pg_class) GETSTRUCT(tuple); - if (rd_rel->reltuples != (float4) 0) - { - rd_rel->reltuples = (float4) 0; - - heap_inplace_update(pg_class, tuple); - } - - heap_freetuple(tuple); - } - - table_close(pg_class, RowExclusiveLock); -} - -/* * storage_name * returns the name corresponding to a typstorage/attstorage enum value */ |