From: Tom Lane Date: Mon, 6 May 2002 02:39:01 +0000 (+0000) Subject: Reorder snapshot checks to save a couple comparisons in the common case, X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=d46e4ef45947ed65ff7fdc208b327c9798d031e2;p=users%2Fbernd%2Fpostgres.git Reorder snapshot checks to save a couple comparisons in the common case, where the tuple's xmin or xmax is older than the snapshot xmin. There is no need to check it against snapshot xmax in that case. --- diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index e42aae284d..34fbd8d830 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -707,13 +707,12 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) * By here, the inserting transaction has committed - have to check * when... */ - - if (TransactionIdFollowsOrEquals(tuple->t_xmin, snapshot->xmax)) - return false; if (TransactionIdFollowsOrEquals(tuple->t_xmin, snapshot->xmin)) { uint32 i; + if (TransactionIdFollowsOrEquals(tuple->t_xmin, snapshot->xmax)) + return false; for (i = 0; i < snapshot->xcnt; i++) { if (TransactionIdEquals(tuple->t_xmin, snapshot->xip[i])) @@ -748,12 +747,15 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) tuple->t_infomask |= HEAP_XMAX_COMMITTED; } - if (TransactionIdFollowsOrEquals(tuple->t_xmax, snapshot->xmax)) - return true; + /* + * OK, the deleting transaction committed too ... but when? + */ if (TransactionIdFollowsOrEquals(tuple->t_xmax, snapshot->xmin)) { uint32 i; + if (TransactionIdFollowsOrEquals(tuple->t_xmax, snapshot->xmax)) + return true; for (i = 0; i < snapshot->xcnt; i++) { if (TransactionIdEquals(tuple->t_xmax, snapshot->xip[i]))