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

Commitdb2687d

Browse files
committed
Optimize PredicateLockTuple().
PredicateLockTuple() has a fast exit if tuple was written by the currenttransaction, as in that case it already has a lock. This check can beperformed using TransactionIdIsCurrentTransactionId() instead ofSubTransGetTopmostTransaction(), to avoid any chance of having to hit thedisk.Author: Ashwin Agrawal, based on a suggestion from Andres FreundReviewed-by: Thomas MunroDiscussion:https://postgr.es/m/CALfoeiv0k3hkEb3Oqk%3DziWqtyk2Jys1UOK5hwRBNeANT_yX%2Bng%40mail.gmail.com
1 parent695c597 commitdb2687d

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

‎src/backend/storage/lmgr/predicate.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,7 +2549,6 @@ PredicateLockTuple(Relation relation, HeapTuple tuple, Snapshot snapshot)
25492549
{
25502550
PREDICATELOCKTARGETTAGtag;
25512551
ItemPointertid;
2552-
TransactionIdtargetxmin;
25532552

25542553
if (!SerializationNeededForRead(relation,snapshot))
25552554
return;
@@ -2559,24 +2558,9 @@ PredicateLockTuple(Relation relation, HeapTuple tuple, Snapshot snapshot)
25592558
*/
25602559
if (relation->rd_index==NULL)
25612560
{
2562-
TransactionIdmyxid;
2563-
2564-
targetxmin=HeapTupleHeaderGetXmin(tuple->t_data);
2565-
2566-
myxid=GetTopTransactionIdIfAny();
2567-
if (TransactionIdIsValid(myxid))
2568-
{
2569-
if (TransactionIdFollowsOrEquals(targetxmin,TransactionXmin))
2570-
{
2571-
TransactionIdxid=SubTransGetTopmostTransaction(targetxmin);
2572-
2573-
if (TransactionIdEquals(xid,myxid))
2574-
{
2575-
/* We wrote it; we already have a write lock. */
2576-
return;
2577-
}
2578-
}
2579-
}
2561+
/* If we wrote it; we already have a write lock. */
2562+
if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmin(tuple->t_data)))
2563+
return;
25802564
}
25812565

25822566
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp