diff --git a/doc/src/sgml/mvcc.sgml b/doc/src/sgml/mvcc.sgml index 82e69fe2d27..7aa32932fab 100644 --- a/doc/src/sgml/mvcc.sgml +++ b/doc/src/sgml/mvcc.sgml @@ -923,7 +923,8 @@ ERROR: could not serialize access due to read/write dependencies among transact Acquired by VACUUM (without ), - ANALYZE, CREATE INDEX CONCURRENTLY, and + ANALYZE, CREATE INDEX CONCURRENTLY, + CREATE STATISTICS and ALTER TABLE VALIDATE and other ALTER TABLE variants (for full details see ). 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 &&