Skip site navigation (1) Skip section navigation (2)

Trivial patch to double vacuum speed on tables with no indexes

From: stark <stark(at)enterprisedb(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Trivial patch to double vacuum speed on tables with no indexes
Date: 2006-08-27 14:10:14
Message-ID: 877j0umfqx.fsf@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
There isn't really any need for the second pass in lazy vacuum if the table
has no indexes. The patch seems almost too easy but of course nothing having
to do with vacuum is as easy as it appears. Perhaps there are some gotchas I
haven't thought of?



Index: src/backend/commands/vacuumlazy.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v
retrieving revision 1.76
diff -c -r1.76 vacuumlazy.c
*** src/backend/commands/vacuumlazy.c	31 Jul 2006 20:09:00 -0000	1.76
--- src/backend/commands/vacuumlazy.c	27 Aug 2006 14:06:10 -0000
***************
*** 450,455 ****
--- 450,464 ----
  		{
  			lazy_record_free_space(vacrelstats, blkno,
  								   PageGetFreeSpace(page));
+ 		} else if (!nindexes) {
+ 			/* If there are no indexes we can vacuum the page right now instead
+ 			 * of doing a second scan */
+ 
+ 			LockBuffer(buf, BUFFER_LOCK_UNLOCK);
+ 			LockBufferForCleanup(buf);
+ 			lazy_vacuum_page(onerel, blkno, buf, 0, vacrelstats);
+ 			lazy_record_free_space(vacrelstats, blkno, PageGetFreeSpace(BufferGetPage(buf)));
+ 			vacrelstats->num_dead_tuples = 0;
  		}
  
  		/* Remember the location of the last page with nonremovable tuples */


-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

Responses

pgsql-hackers by date

Next:From: Andrew DunstanDate: 2006-08-27 14:17:44
Subject: Re: Adding fulldisjunctions to the contrib
Previous:From: Jonah H. HarrisDate: 2006-08-27 12:51:57
Subject: Re: Adding fulldisjunctions to the contrib

pgsql-patches by date

Next:From: Andrew DunstanDate: 2006-08-27 14:17:44
Subject: Re: Adding fulldisjunctions to the contrib
Previous:From: Jonah H. HarrisDate: 2006-08-27 12:51:57
Subject: Re: Adding fulldisjunctions to the contrib

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group