*/
for (index = 0; index < arrayP->numProcs; index++)
{
- int pgprocno = arrayP->pgprocnos[index];
- PGPROC *proc = &allProcs[pgprocno];
TransactionId xid;
/* Fetch xid just once - see GetNewTransactionId */
oldestRunningXid = xid;
/*
- * Also, update the oldest running xid within the current database.
+ * Also, update the oldest running xid within the current database. As
+ * fetching pgprocno and PGPROC could cause cache misses, we do cheap
+ * TransactionId comparison first.
*/
- if (proc->databaseId == MyDatabaseId &&
- TransactionIdPrecedes(xid, oldestDatabaseRunningXid))
- oldestDatabaseRunningXid = xid;
+ if (TransactionIdPrecedes(xid, oldestDatabaseRunningXid))
+ {
+ int pgprocno = arrayP->pgprocnos[index];
+ PGPROC *proc = &allProcs[pgprocno];
+
+ if (proc->databaseId == MyDatabaseId)
+ oldestDatabaseRunningXid = xid;
+ }
if (ProcGlobal->subxidStates[index].overflowed)
suboverflowed = true;