From f425b605f4e97a4571372b116a1ec81daf88dfc8 Mon Sep 17 00:00:00 2001 From: Jan Wieck Date: Fri, 6 Feb 2004 19:36:18 +0000 Subject: Cost based vacuum delay feature. Jan --- src/backend/access/nbtree/nbtree.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/backend/access/nbtree/nbtree.c') diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index b423c8fdbe8..87a251915a5 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.110 2004/02/03 17:34:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.111 2004/02/06 19:36:17 wieck Exp $ * *------------------------------------------------------------------------- */ @@ -586,6 +586,26 @@ btbulkdelete(PG_FUNCTION_ARGS) CHECK_FOR_INTERRUPTS(); + /* + * If we're called by a cost based vacuum, do the + * napping in case the balance exceeded the limit. + */ + if (VacuumCostActive && !InterruptPending && + VacuumCostBalance >= VacuumCostLimit) + { + int msec; + + msec = VacuumCostNaptime * VacuumCostBalance / VacuumCostLimit; + if (msec < VacuumCostNaptime * 4) + PG_MSLEEP(msec); + else + PG_MSLEEP(VacuumCostNaptime * 4); + + VacuumCostBalance = 0; + + CHECK_FOR_INTERRUPTS(); + } + ndeletable = 0; page = BufferGetPage(buf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); -- cgit v1.2.3