aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2017-04-05 18:22:32 -0400
committerSimon Riggs <simon@2ndQuadrant.com>2017-04-05 18:22:32 -0400
commit68ea2b7f9b52d35b5fcd9c8d44d88de5a64be3ba (patch)
treeef650aa6a264e2131f56971399b1a04dd8f588c8 /src
parent2686ee1b7ccfb9214064d4d2a98ea77382880306 (diff)
downloadpostgresql-68ea2b7f9b52d35b5fcd9c8d44d88de5a64be3ba.tar.gz
postgresql-68ea2b7f9b52d35b5fcd9c8d44d88de5a64be3ba.zip
Reduce lock level for CREATE STATISTICS
In line with other lock reductions related to planning. Simon Riggs
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/statscmds.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index 8d483dbb3a7..46abadcc811 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -96,7 +96,13 @@ CreateStatistics(CreateStatsStmt *stmt)
errmsg("statistics \"%s\" already exist", namestr)));
}
- rel = heap_openrv(stmt->relation, AccessExclusiveLock);
+ /*
+ * CREATE STATISTICS will influence future execution plans but does
+ * not interfere with currently executing plans so it is safe to
+ * take only ShareUpdateExclusiveLock on relation, conflicting with
+ * ANALYZE and other DDL that sets statistical information.
+ */
+ rel = heap_openrv(stmt->relation, ShareUpdateExclusiveLock);
relid = RelationGetRelid(rel);
if (rel->rd_rel->relkind != RELKIND_RELATION &&