mirror of
https://github.com/postgres/postgres.git
synced 2025-08-31 17:02:12 +03:00
Centralize implementation of delay code by creating a pg_usleep()
subroutine in src/port/pgsleep.c. Remove platform dependencies from miscadmin.h and put them in port.h where they belong. Extend recent vacuum cost-based-delay patch to apply to VACUUM FULL, ANALYZE, and non-btree index vacuuming. By the way, where is the documentation for the cost-based-delay patch?
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.36 2004/02/10 01:55:25 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.37 2004/02/10 03:42:44 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -148,10 +148,6 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
|
||||
vac_open_indexes(onerel, &nindexes, &Irel);
|
||||
hasindex = (nindexes > 0);
|
||||
|
||||
/* Turn vacuum cost accounting on or off */
|
||||
VacuumCostActive = (VacuumCostNaptime > 0);
|
||||
VacuumCostBalance = 0;
|
||||
|
||||
/* Do the vacuuming */
|
||||
lazy_scan_heap(onerel, vacrelstats, Irel, nindexes);
|
||||
|
||||
@@ -172,9 +168,6 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
|
||||
/* Update shared free space map with final free space info */
|
||||
lazy_update_fsm(onerel, vacrelstats);
|
||||
|
||||
/* Turn off vacuum cost accounting */
|
||||
VacuumCostActive = false;
|
||||
|
||||
/* Update statistics in pg_class */
|
||||
vac_update_relstats(RelationGetRelid(onerel), vacrelstats->rel_pages,
|
||||
vacrelstats->rel_tuples, hasindex);
|
||||
@@ -233,26 +226,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
|
||||
hastup;
|
||||
int prev_dead_count;
|
||||
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
/*
|
||||
* Do the napping in a cost based vacuum.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
vacuum_delay_point();
|
||||
|
||||
/*
|
||||
* If we are close to overrunning the available space for
|
||||
@@ -493,26 +467,7 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
|
||||
Buffer buf;
|
||||
Page page;
|
||||
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
/*
|
||||
* Do the napping in a cost based vacuum.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
vacuum_delay_point();
|
||||
|
||||
tblk = ItemPointerGetBlockNumber(&vacrelstats->dead_tuples[tupindex]);
|
||||
buf = ReadBuffer(onerel, tblk);
|
||||
@@ -845,26 +800,7 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
|
||||
tupgone,
|
||||
hastup;
|
||||
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
/*
|
||||
* Do the napping in a cost based vacuum.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
vacuum_delay_point();
|
||||
|
||||
blkno--;
|
||||
|
||||
|
Reference in New Issue
Block a user