(unnamed)

text/plain

Filename: (unnamed)
Type: text/plain
Part: 0
Message: Experimental patch for inter-page delay in VACUUM
*** src/backend/access/nbtree/nbtree.c.orig	Mon Sep 29 19:40:26 2003
--- src/backend/access/nbtree/nbtree.c	Thu Oct 30 21:02:55 2003
***************
*** 18,23 ****
--- 18,25 ----
   */
  #include "postgres.h"
  
+ #include <unistd.h>
+ 
  #include "access/genam.h"
  #include "access/heapam.h"
  #include "access/nbtree.h"
***************
*** 27,32 ****
--- 29,37 ----
  #include "storage/smgr.h"
  
  
+ extern int	vacuum_page_delay;
+ 
+ 
  /* Working state for btbuild and its callback */
  typedef struct
  {
***************
*** 610,615 ****
--- 615,623 ----
  
  			CHECK_FOR_INTERRUPTS();
  
+ 			if (vacuum_page_delay > 0)
+ 				usleep(vacuum_page_delay * 1000);
+ 
  			ndeletable = 0;
  			page = BufferGetPage(buf);
  			opaque = (BTPageOpaque) PageGetSpecialPointer(page);
***************
*** 736,741 ****
--- 744,754 ----
  		Buffer		buf;
  		Page		page;
  		BTPageOpaque opaque;
+ 
+ 		CHECK_FOR_INTERRUPTS();
+ 
+ 		if (vacuum_page_delay > 0)
+ 			usleep(vacuum_page_delay * 1000);
  
  		buf = _bt_getbuf(rel, blkno, BT_READ);
  		page = BufferGetPage(buf);
*** src/backend/commands/vacuumlazy.c.orig	Thu Sep 25 10:22:58 2003
--- src/backend/commands/vacuumlazy.c	Thu Oct 30 21:07:58 2003
***************
*** 37,42 ****
--- 37,44 ----
   */
  #include "postgres.h"
  
+ #include <unistd.h>
+ 
  #include "access/genam.h"
  #include "access/heapam.h"
  #include "access/xlog.h"
***************
*** 88,93 ****
--- 90,97 ----
  static TransactionId OldestXmin;
  static TransactionId FreezeLimit;
  
+ int		vacuum_page_delay = 0;	/* milliseconds per page */
+ 
  
  /* non-export function prototypes */
  static void lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
***************
*** 228,233 ****
--- 232,240 ----
  
  		CHECK_FOR_INTERRUPTS();
  
+ 		if (vacuum_page_delay > 0)
+ 			usleep(vacuum_page_delay * 1000);
+ 
  		/*
  		 * If we are close to overrunning the available space for
  		 * dead-tuple TIDs, pause and do a cycle of vacuuming before we
***************
*** 469,474 ****
--- 476,484 ----
  
  		CHECK_FOR_INTERRUPTS();
  
+ 		if (vacuum_page_delay > 0)
+ 			usleep(vacuum_page_delay * 1000);
+ 
  		tblk = ItemPointerGetBlockNumber(&vacrelstats->dead_tuples[tupindex]);
  		buf = ReadBuffer(onerel, tblk);
  		LockBufferForCleanup(buf);
***************
*** 799,804 ****
--- 809,817 ----
  					hastup;
  
  		CHECK_FOR_INTERRUPTS();
+ 
+ 		if (vacuum_page_delay > 0)
+ 			usleep(vacuum_page_delay * 1000);
  
  		blkno--;
  
*** src/backend/utils/misc/guc.c.orig	Sun Oct 19 19:47:54 2003
--- src/backend/utils/misc/guc.c	Thu Oct 30 21:15:46 2003
***************
*** 73,78 ****
--- 73,79 ----
  extern int	CommitDelay;
  extern int	CommitSiblings;
  extern char *preload_libraries_string;
+ extern int	vacuum_page_delay;
  
  #ifdef HAVE_SYSLOG
  extern char *Syslog_facility;
***************
*** 1188,1193 ****
--- 1189,1203 ----
  		},
  		&log_min_duration_statement,
  		-1, -1, INT_MAX / 1000, NULL, NULL
+ 	},
+ 
+ 	{
+ 		{"vacuum_page_delay", PGC_USERSET, CLIENT_CONN_STATEMENT,
+ 			gettext_noop("Sets VACUUM's delay in milliseconds between processing successive pages."),
+ 			NULL
+ 		},
+ 		&vacuum_page_delay,
+ 		0, 0, 100, NULL, NULL
  	},
  
  	/* End-of-list marker */