summaryrefslogtreecommitdiff
path: root/src/backend/access/nbtree/nbtpage.c
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2011-11-18 16:06:53 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2011-11-18 16:06:53 +0000
commitc1458cc495ff800cd176a1c2e56d8b62680d9b71 (patch)
treeb13653180e37885d81bfbdd838318506d742caf9 /src/backend/access/nbtree/nbtpage.c
parentf6438f66226e37851e11a93edebae0198a875100 (diff)
downloadpostgresql-c1458cc495ff800cd176a1c2e56d8b62680d9b71.tar.gz
Avoid marking buffer dirty when VACUUM has no work to do.
When wal_level = 'hot_standby' we touched the last page of the relation during a VACUUM, even if nothing else had happened. That would alter the LSN of the last block and set the mtime of the relation file unnecessarily. Noted by Thom Brown.
Diffstat (limited to 'src/backend/access/nbtree/nbtpage.c')
-rw-r--r--src/backend/access/nbtree/nbtpage.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index f9b3e1feaf..6f6e676ec0 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -732,7 +732,7 @@ _bt_page_recyclable(Page page)
* and so must be scanned anyway during replay. We always write a WAL record
* for the last block in the index, whether or not it contained any items
* to be removed. This allows us to scan right up to end of index to
- * ensure correct locking.
+ * ensure correct locking. That is the only time we are called with nitems==0.
*/
void
_bt_delitems_vacuum(Relation rel, Buffer buf,
@@ -764,7 +764,8 @@ _bt_delitems_vacuum(Relation rel, Buffer buf,
*/
opaque->btpo_flags &= ~BTP_HAS_GARBAGE;
- MarkBufferDirty(buf);
+ if (nitems > 0)
+ MarkBufferDirty(buf);
/* XLOG stuff */
if (RelationNeedsWAL(rel))
@@ -804,8 +805,11 @@ _bt_delitems_vacuum(Relation rel, Buffer buf,
recptr = XLogInsert(RM_BTREE_ID, XLOG_BTREE_VACUUM, rdata);
- PageSetLSN(page, recptr);
- PageSetTLI(page, ThisTimeLineID);
+ if (nitems > 0)
+ {
+ PageSetLSN(page, recptr);
+ PageSetTLI(page, ThisTimeLineID);
+ }
}
END_CRIT_SECTION();