Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9d306c6

Browse files
committed
Avoid unnecessary page-level SSI lock check in heap_insert().
As observed by Heikki, we need not conflict on heap page locks during aninsert; heap page locks are only aggregated tuple locks, they don't implylocking "gaps" as index page locks do. So we can avoid some unnecessaryconflicts, and also do the SSI check while not holding exclusive lock onthe target buffer.Kevin Grittner, reviewed by Jeff Davis. Back-patch to 9.1.
1 parente6ed34f commit9d306c6

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,18 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
19161916
else
19171917
heaptup=tup;
19181918

1919+
/*
1920+
* We're about to do the actual insert -- but check for conflict first,
1921+
* to avoid possibly having to roll back work we've just done.
1922+
*
1923+
* For a heap insert, we only need to check for table-level SSI locks.
1924+
* Our new tuple can't possibly conflict with existing tuple locks, and
1925+
* heap page locks are only consolidated versions of tuple locks; they do
1926+
* not lock "gaps" as index page locks do. So we don't need to identify
1927+
* a buffer before making the call.
1928+
*/
1929+
CheckForSerializableConflictIn(relation,NULL,InvalidBuffer);
1930+
19191931
/*
19201932
* Find buffer to insert this tuple into. If the page is all visible,
19211933
* this will also pin the requisite visibility map page.
@@ -1924,13 +1936,6 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
19241936
InvalidBuffer,options,bistate,
19251937
&vmbuffer,NULL);
19261938

1927-
/*
1928-
* We're about to do the actual insert -- check for conflict at the
1929-
* relation or buffer level first, to avoid possibly having to roll back
1930-
* work we've just done.
1931-
*/
1932-
CheckForSerializableConflictIn(relation,NULL,buffer);
1933-
19341939
/* NO EREPORT(ERROR) from here till changes are logged */
19351940
START_CRIT_SECTION();
19361941

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp