Skip to content
Snippets Groups Projects
Commit 68ea2b7f authored by Simon Riggs's avatar Simon Riggs
Browse files

Reduce lock level for CREATE STATISTICS

In line with other lock reductions related to planning.

Simon Riggs
parent 2686ee1b
No related branches found
No related tags found
No related merge requests found
......@@ -923,7 +923,8 @@ ERROR: could not serialize access due to read/write dependencies among transact
<para>
Acquired by <command>VACUUM</command> (without <option>FULL</option>),
<command>ANALYZE</>, <command>CREATE INDEX CONCURRENTLY</>, and
<command>ANALYZE</>, <command>CREATE INDEX CONCURRENTLY</>,
<command>CREATE STATISTICS</> and
<command>ALTER TABLE VALIDATE</command> and other
<command>ALTER TABLE</command> variants (for full details see
<xref linkend="SQL-ALTERTABLE">).
......
......@@ -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 &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment