diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2024-05-23 02:22:40 +0300 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2024-05-23 02:22:41 +0300 |
commit | fbd4321fd5b4400fbbf356d686af6ad6d3208c66 (patch) | |
tree | 90ae1e556c44d977bebca6c8bfd0d2f12470d28e /src/backend/commands/tablecmds.c | |
parent | 3a82c689fd1be9bdf9d60135e5db7d352c051269 (diff) | |
download | postgresql-fbd4321fd5b4400fbbf356d686af6ad6d3208c66.tar.gz postgresql-fbd4321fd5b4400fbbf356d686af6ad6d3208c66.zip |
Don't copy extended statistics during MERGE/SPLIT partition operations
When MERGE/SPLIT created new partitions, it was cloning the extended
statistics of the parent table.
However, extended stats on partitioned tables don't behave like
indexes on partitioned tables (which exist only to create physical
indexes on child tables). Rather, extended stats on a parent 1) cause
extended stats to be collected and computed across the whole partition
hierarchy, and 2) do not cause extended stats to be computed for the
individual partitions.
"CREATE TABLE ... PARTITION OF" command doesn't copy extended
statistics. This commit makes createPartitionTable() behave
consistently.
Reported-by: Justin Pryzby
Discussion: https://postgr.es/m/ZiJW1g2nbQs9ekwK%40pryzbyj2023
Author: Alexander Korotkov, Justin Pryzby
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 7a063ca8ae0..7b6c69b7a52 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -20269,7 +20269,7 @@ moveSplitTableRows(Relation rel, Relation splitRel, List *partlist, List *newPar * (newPartName) like table (modelRel) * * Emulates command: CREATE [TEMP] TABLE <newPartName> (LIKE <modelRel's name> - * INCLUDING ALL EXCLUDING INDEXES EXCLUDING IDENTITY) + * INCLUDING ALL EXCLUDING INDEXES EXCLUDING IDENTITY EXCLUDING STATISTICS) * * Also, this function sets the new partition access method same as parent * table access methods (similarly to CREATE TABLE ... PARTITION OF). It @@ -20313,9 +20313,11 @@ createPartitionTable(RangeVar *newPartName, Relation modelRel, /* * Indexes will be inherited on "attach new partitions" stage, after data - * moving. + * moving. We also don't copy the extended statistics for consistency + * with CREATE TABLE PARTITION OF. */ - tlc->options = CREATE_TABLE_LIKE_ALL & ~(CREATE_TABLE_LIKE_INDEXES | CREATE_TABLE_LIKE_IDENTITY); + tlc->options = CREATE_TABLE_LIKE_ALL & + ~(CREATE_TABLE_LIKE_INDEXES | CREATE_TABLE_LIKE_IDENTITY | CREATE_TABLE_LIKE_STATISTICS); tlc->relationOid = InvalidOid; createStmt->tableElts = lappend(createStmt->tableElts, tlc); |