*** a/src/backend/storage/buffer/buf_init.c
--- b/src/backend/storage/buffer/buf_init.c
*************** InitBufferPool(void)
*** 104,109 ****
--- 104,110 ----
  			CLEAR_BUFFERTAG(buf->tag);
  			buf->flags = 0;
  			buf->usage_count = 0;
+ 			INSTR_TIME_SET_ZERO(buf->used);
  			buf->refcount = 0;
  			buf->wait_backend_pid = 0;
  
*** a/src/backend/storage/buffer/bufmgr.c
--- b/src/backend/storage/buffer/bufmgr.c
*************** BufferAlloc(SMgrRelation smgr, char relp
*** 843,849 ****
  		buf->flags |= BM_TAG_VALID | BM_PERMANENT;
  	else
  		buf->flags |= BM_TAG_VALID;
! 	buf->usage_count = 1;
  
  	UnlockBufHdr(buf);
  
--- 843,850 ----
  		buf->flags |= BM_TAG_VALID | BM_PERMANENT;
  	else
  		buf->flags |= BM_TAG_VALID;
! 	buf->usage_count = 3;
! 	INSTR_TIME_SET_ZERO(buf->used);
  
  	UnlockBufHdr(buf);
  
*************** retry:
*** 954,959 ****
--- 955,961 ----
  	CLEAR_BUFFERTAG(buf->tag);
  	buf->flags = 0;
  	buf->usage_count = 0;
+ 	INSTR_TIME_SET_ZERO(buf->used);
  
  	UnlockBufHdr(buf);
  
*************** PinBuffer(volatile BufferDesc *buf, Buff
*** 1099,1110 ****
  
  	if (PrivateRefCount[b] == 0)
  	{
  		LockBufHdr(buf);
  		buf->refcount++;
  		if (strategy == NULL)
  		{
! 			if (buf->usage_count < BM_MAX_USAGE_COUNT)
  				buf->usage_count++;
  		}
  		else
  		{
--- 1101,1124 ----
  
  	if (PrivateRefCount[b] == 0)
  	{
+ 		instr_time	now, orig;
+ 
+ 		INSTR_TIME_SET_CURRENT(now);
+ 		orig = now;
  		LockBufHdr(buf);
  		buf->refcount++;
  		if (strategy == NULL)
  		{
! 			double secs;
! 
! 			INSTR_TIME_SUBTRACT(now, buf->used);
! 			secs = INSTR_TIME_GET_DOUBLE(now);
! 
! 			if (buf->usage_count < BM_MAX_USAGE_COUNT && secs > 3)
! 			{
  				buf->usage_count++;
+ 				buf->used = orig;
+ 			}
  		}
  		else
  		{
*** a/src/backend/storage/buffer/localbuf.c
--- b/src/backend/storage/buffer/localbuf.c
*************** LocalBufferAlloc(SMgrRelation smgr, Fork
*** 254,259 ****
--- 254,260 ----
  	bufHdr->flags &= ~(BM_VALID | BM_DIRTY | BM_JUST_DIRTIED | BM_IO_ERROR);
  	bufHdr->flags |= BM_TAG_VALID;
  	bufHdr->usage_count = 1;
+ 	INSTR_TIME_SET_ZERO(bufHdr->used);
  
  	*foundPtr = FALSE;
  	return bufHdr;
*************** DropRelFileNodeLocalBuffers(RelFileNode
*** 330,335 ****
--- 331,337 ----
  			CLEAR_BUFFERTAG(bufHdr->tag);
  			bufHdr->flags = 0;
  			bufHdr->usage_count = 0;
+ 			INSTR_TIME_SET_ZERO(bufHdr->used);
  		}
  	}
  }
*************** DropRelFileNodeAllLocalBuffers(RelFileNo
*** 370,375 ****
--- 372,378 ----
  			CLEAR_BUFFERTAG(bufHdr->tag);
  			bufHdr->flags = 0;
  			bufHdr->usage_count = 0;
+ 			INSTR_TIME_SET_ZERO(bufHdr->used);
  		}
  	}
  }
*** a/src/include/storage/buf_internals.h
--- b/src/include/storage/buf_internals.h
***************
*** 15,20 ****
--- 15,21 ----
  #ifndef BUFMGR_INTERNALS_H
  #define BUFMGR_INTERNALS_H
  
+ #include "portability/instr_time.h"
  #include "storage/buf.h"
  #include "storage/latch.h"
  #include "storage/lwlock.h"
*************** typedef bits16 BufFlags;
*** 51,57 ****
   * clock sweeps to find a free buffer, so in practice we don't want the
   * value to be very large.
   */
! #define BM_MAX_USAGE_COUNT	5
  
  /*
   * Buffer tag identifies which disk block the buffer contains.
--- 52,58 ----
   * clock sweeps to find a free buffer, so in practice we don't want the
   * value to be very large.
   */
! #define BM_MAX_USAGE_COUNT	10
  
  /*
   * Buffer tag identifies which disk block the buffer contains.
*************** typedef struct buftag
*** 113,119 ****
   *	BufferDesc -- shared descriptor/state data for a single shared buffer.
   *
   * Note: buf_hdr_lock must be held to examine or change the tag, flags,
!  * usage_count, refcount, or wait_backend_pid fields.  buf_id field never
   * changes after initialization, so does not need locking.	freeNext is
   * protected by the BufFreelistLock not buf_hdr_lock.  The LWLocks can take
   * care of themselves.	The buf_hdr_lock is *not* used to control access to
--- 114,120 ----
   *	BufferDesc -- shared descriptor/state data for a single shared buffer.
   *
   * Note: buf_hdr_lock must be held to examine or change the tag, flags,
!  * usage_count, used, refcount, or wait_backend_pid fields.  buf_id field never
   * changes after initialization, so does not need locking.	freeNext is
   * protected by the BufFreelistLock not buf_hdr_lock.  The LWLocks can take
   * care of themselves.	The buf_hdr_lock is *not* used to control access to
*************** typedef struct sbufdesc
*** 139,144 ****
--- 140,146 ----
  	BufferTag	tag;			/* ID of page contained in buffer */
  	BufFlags	flags;			/* see bit definitions above */
  	uint16		usage_count;	/* usage counter for clock sweep code */
+ 	instr_time	used;			/* Time of last refcount increment */
  	unsigned	refcount;		/* # of backends holding pins on buffer */
  	int			wait_backend_pid;		/* backend PID of pin-count waiter */
  
