diff -x '*.sql' -x '*.o' -x '*.txt' -rupN postgresql-9.1alpha4/src/backend/access/heap/heapam.c postgresql-9.1alpha4_hbcache/src/backend/access/heap/heapam.c
--- postgresql-9.1alpha4/src/backend/access/heap/heapam.c	2011-03-09 08:19:24.000000000 -0600
+++ postgresql-9.1alpha4_hbcache/src/backend/access/heap/heapam.c	2011-03-30 13:27:15.483195001 -0500
@@ -1793,12 +1793,13 @@ UpdateXmaxHintBits(HeapTupleHeader tuple
 
 	if (!(tuple->t_infomask & (HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID)))
 	{
-		if (TransactionIdDidCommit(xid))
-			HeapTupleSetHintBits(tuple, buffer, HEAP_XMAX_COMMITTED,
-								 xid);
+		bool cache_hit;
+		if (TransactionIdDidCommitCache(xid, &cache_hit))
+			HeapTupleSetHintBitsCache(tuple, buffer, HEAP_XMAX_COMMITTED,
+								 xid, cache_hit);
 		else
-			HeapTupleSetHintBits(tuple, buffer, HEAP_XMAX_INVALID,
-								 InvalidTransactionId);
+			HeapTupleSetHintBitsCache(tuple, buffer, HEAP_XMAX_INVALID,
+								 InvalidTransactionId, cache_hit);
 	}
 }
 
diff -x '*.sql' -x '*.o' -x '*.txt' -rupN postgresql-9.1alpha4/src/backend/access/transam/transam.c postgresql-9.1alpha4_hbcache/src/backend/access/transam/transam.c
--- postgresql-9.1alpha4/src/backend/access/transam/transam.c	2011-03-09 08:19:24.000000000 -0600
+++ postgresql-9.1alpha4_hbcache/src/backend/access/transam/transam.c	2011-03-30 13:15:32.871195002 -0500
@@ -39,7 +39,7 @@ static XLogRecPtr cachedCommitLSN;
 static const XLogRecPtr InvalidXLogRecPtr = {0, 0};
 
 /* Local functions */
-static XidStatus TransactionLogFetch(TransactionId transactionId);
+static XidStatus TransactionLogFetch(TransactionId transactionId, bool *hit_cache);
 
 
 /* ----------------------------------------------------------------
@@ -53,7 +53,7 @@ static XidStatus TransactionLogFetch(Tra
  * TransactionLogFetch --- fetch commit status of specified transaction id
  */
 static XidStatus
-TransactionLogFetch(TransactionId transactionId)
+TransactionLogFetch(TransactionId transactionId, bool *cache_hit)
 {
 	XidStatus	xidstatus;
 	XLogRecPtr	xidlsn;
@@ -63,7 +63,14 @@ TransactionLogFetch(TransactionId transa
 	 * see if we didn't just check the transaction status a moment ago.
 	 */
 	if (TransactionIdEquals(transactionId, cachedFetchXid))
+	{
+		if(cache_hit != NULL) 
+			*cache_hit = TRUE;
 		return cachedFetchXidStatus;
+	}
+
+	if(cache_hit != NULL) *cache_hit = FALSE;
+        
 
 	/*
 	 * Also, check to see if the transaction ID is a permanent one.
@@ -126,11 +133,11 @@ TransactionLogFetch(TransactionId transa
  *		Assumes transaction identifier is valid.
  */
 bool							/* true if given transaction committed */
-TransactionIdDidCommit(TransactionId transactionId)
+TransactionIdDidCommitCache(TransactionId transactionId, bool *cache_hit)
 {
 	XidStatus	xidstatus;
 
-	xidstatus = TransactionLogFetch(transactionId);
+	xidstatus = TransactionLogFetch(transactionId, cache_hit);
 
 	/*
 	 * If it's marked committed, it's committed.
@@ -165,7 +172,7 @@ TransactionIdDidCommit(TransactionId tra
 				 transactionId);
 			return false;
 		}
-		return TransactionIdDidCommit(parentXid);
+		return TransactionIdDidCommitCache(parentXid, cache_hit);
 	}
 
 	/*
@@ -182,11 +189,11 @@ TransactionIdDidCommit(TransactionId tra
  *		Assumes transaction identifier is valid.
  */
 bool							/* true if given transaction aborted */
-TransactionIdDidAbort(TransactionId transactionId)
+TransactionIdDidAbortCache(TransactionId transactionId, bool *cache_hit)
 {
 	XidStatus	xidstatus;
 
-	xidstatus = TransactionLogFetch(transactionId);
+	xidstatus = TransactionLogFetch(transactionId, cache_hit);
 
 	/*
 	 * If it's marked aborted, it's aborted.
@@ -214,7 +221,7 @@ TransactionIdDidAbort(TransactionId tran
 				 transactionId);
 			return true;
 		}
-		return TransactionIdDidAbort(parentXid);
+		return TransactionIdDidAbortCache(parentXid, cache_hit);
 	}
 
 	/*
diff -x '*.sql' -x '*.o' -x '*.txt' -rupN postgresql-9.1alpha4/src/backend/utils/time/tqual.c postgresql-9.1alpha4_hbcache/src/backend/utils/time/tqual.c
--- postgresql-9.1alpha4/src/backend/utils/time/tqual.c	2011-03-09 08:19:24.000000000 -0600
+++ postgresql-9.1alpha4_hbcache/src/backend/utils/time/tqual.c	2011-03-30 13:51:16.343195002 -0500
@@ -104,9 +104,10 @@ static bool XidInMVCCSnapshot(Transactio
  * The caller should pass xid as the XID of the transaction to check, or
  * InvalidTransactionId if no check is needed.
  */
+#define SetHintBits(t, b, i, x) SetHintBitsCache((t), (b), (i), (x), false)
 static inline void
-SetHintBits(HeapTupleHeader tuple, Buffer buffer,
-			uint16 infomask, TransactionId xid)
+SetHintBitsCache(HeapTupleHeader tuple, Buffer buffer,
+			uint16 infomask, TransactionId xid, bool cache_hit)
 {
 	if (TransactionIdIsValid(xid))
 	{
@@ -118,7 +119,8 @@ SetHintBits(HeapTupleHeader tuple, Buffe
 	}
 
 	tuple->t_infomask |= infomask;
-	SetBufferCommitInfoNeedsSave(buffer);
+        if (!cache_hit)
+		SetBufferCommitInfoNeedsSave(buffer);
 }
 
 /*
@@ -128,10 +130,10 @@ SetHintBits(HeapTupleHeader tuple, Buffe
  * implement inline functions.
  */
 void
-HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
-					 uint16 infomask, TransactionId xid)
+HeapTupleSetHintBitsCache(HeapTupleHeader tuple, Buffer buffer,
+					 uint16 infomask, TransactionId xid, bool cache_hit)
 {
-	SetHintBits(tuple, buffer, infomask, xid);
+	SetHintBitsCache(tuple, buffer, infomask, xid, cache_hit);
 }
 
 
@@ -912,6 +914,8 @@ bool
 HeapTupleSatisfiesMVCC(HeapTupleHeader tuple, Snapshot snapshot,
 					   Buffer buffer)
 {
+	bool cache_hit;
+
 	if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
 	{
 		if (tuple->t_infomask & HEAP_XMIN_INVALID)
@@ -984,9 +988,9 @@ HeapTupleSatisfiesMVCC(HeapTupleHeader t
 		}
 		else if (TransactionIdIsInProgress(HeapTupleHeaderGetXmin(tuple)))
 			return false;
-		else if (TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple)))
-			SetHintBits(tuple, buffer, HEAP_XMIN_COMMITTED,
-						HeapTupleHeaderGetXmin(tuple));
+		else if (TransactionIdDidCommitCache(HeapTupleHeaderGetXmin(tuple), &cache_hit))
+			SetHintBitsCache(tuple, buffer, HEAP_XMIN_COMMITTED,
+						HeapTupleHeaderGetXmin(tuple), cache_hit);
 		else
 		{
 			/* it must have aborted or crashed */
