Skip to content

Commit 695c597

Browse files
committed
Optimize TransactionIdIsCurrentTransactionId().
If the passed in xid is the current top transaction, we can do a fast check and exit early. This should work well for the current heap but also works very well for proposed AMs that don't use a separate xid for subtransactions. Author: Ashwin Agrawal, based on a suggestion from Andres Freund Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CALfoeiv0k3hkEb3Oqk%3DziWqtyk2Jys1UOK5hwRBNeANT_yX%2Bng%40mail.gmail.com
1 parent 9fab25c commit 695c597

File tree

1 file changed

+3
-0
lines changed
  • src/backend/access/transam

1 file changed

+3
-0
lines changed

src/backend/access/transam/xact.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,9 @@ TransactionIdIsCurrentTransactionId(TransactionId xid)
871871
if (!TransactionIdIsNormal(xid))
872872
return false;
873873

874+
if (TransactionIdEquals(xid, GetTopTransactionIdIfAny()))
875+
return true;
876+
874877
/*
875878
* In parallel workers, the XIDs we must consider as current are stored in
876879
* ParallelCurrentXids rather than the transaction-state stack. Note that

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy