diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-02-10 03:42:45 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-02-10 03:42:45 +0000 |
commit | 58f337a3435cd6ac46dfca4ce1a44b837080745e (patch) | |
tree | 03e4a309f7ada6914474c02fd9b53df7ab1da975 /src/backend/access | |
parent | 87bd95638552b8fc1f5f787ce5b862bb6fc2eb80 (diff) | |
download | postgresql-58f337a3435cd6ac46dfca4ce1a44b837080745e.tar.gz postgresql-58f337a3435cd6ac46dfca4ce1a44b837080745e.zip |
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?
Diffstat (limited to 'src/backend/access')
-rw-r--r-- | src/backend/access/gist/gist.c | 5 | ||||
-rw-r--r-- | src/backend/access/hash/hash.c | 5 | ||||
-rw-r--r-- | src/backend/access/nbtree/nbtree.c | 25 | ||||
-rw-r--r-- | src/backend/access/rtree/rtree.c | 5 | ||||
-rw-r--r-- | src/backend/access/transam/xact.c | 5 |
5 files changed, 17 insertions, 28 deletions
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index 65a10490d1e..b117b33f72d 100644 --- a/src/backend/access/gist/gist.c +++ b/src/backend/access/gist/gist.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.107 2004/01/07 18:56:23 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.108 2004/02/10 03:42:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -19,6 +19,7 @@ #include "access/gistscan.h" #include "access/heapam.h" #include "catalog/index.h" +#include "commands/vacuum.h" #include "miscadmin.h" @@ -1614,6 +1615,8 @@ gistbulkdelete(PG_FUNCTION_ARGS) while (index_getnext_indexitem(iscan, ForwardScanDirection)) { + vacuum_delay_point(); + if (callback(&iscan->xs_ctup.t_self, callback_state)) { ItemPointerData indextup = iscan->currentItemData; diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index 5ada6b34d87..c1c3cde6fc0 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.70 2004/01/07 18:56:23 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.71 2004/02/10 03:42:43 tgl Exp $ * * NOTES * This file contains only the public interface routines. @@ -23,6 +23,7 @@ #include "access/heapam.h" #include "access/xlogutils.h" #include "catalog/index.h" +#include "commands/vacuum.h" #include "executor/executor.h" #include "miscadmin.h" @@ -514,6 +515,8 @@ loop_top: OffsetNumber maxoffno; bool page_dirty = false; + vacuum_delay_point(); + buf = _hash_getbuf(rel, blkno, HASH_WRITE); page = BufferGetPage(buf); _hash_checkpage(rel, page, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE); diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index fa77318ea3f..79a69a7043f 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.112 2004/02/10 01:55:24 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.113 2004/02/10 03:42:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -22,6 +22,7 @@ #include "access/heapam.h" #include "access/nbtree.h" #include "catalog/index.h" +#include "commands/vacuum.h" #include "miscadmin.h" #include "storage/freespace.h" #include "storage/smgr.h" @@ -584,27 +585,7 @@ btbulkdelete(PG_FUNCTION_ARGS) maxoff; BlockNumber nextpage; - 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(); - } + vacuum_delay_point(); ndeletable = 0; page = BufferGetPage(buf); diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c index 9414e314289..f713a5e7f6b 100644 --- a/src/backend/access/rtree/rtree.c +++ b/src/backend/access/rtree/rtree.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/rtree/rtree.c,v 1.82 2004/01/07 18:56:24 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/access/rtree/rtree.c,v 1.83 2004/02/10 03:42:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -20,6 +20,7 @@ #include "access/rtree.h" #include "access/xlogutils.h" #include "catalog/index.h" +#include "commands/vacuum.h" #include "executor/executor.h" #include "miscadmin.h" @@ -1219,6 +1220,8 @@ rtbulkdelete(PG_FUNCTION_ARGS) while (index_getnext_indexitem(iscan, ForwardScanDirection)) { + vacuum_delay_point(); + if (callback(&iscan->xs_ctup.t_self, callback_state)) { ItemPointerData indextup = iscan->currentItemData; diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 06e152d1bba..5aeb70f2986 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.162 2004/02/10 01:55:24 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.163 2004/02/10 03:42:43 tgl Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -142,7 +142,6 @@ #include "postgres.h" #include <unistd.h> -#include <sys/time.h> #include "access/gistscan.h" #include "access/hash.h" @@ -562,7 +561,7 @@ RecordTransactionCommit(void) */ if (CommitDelay > 0 && enableFsync && CountActiveBackends() >= CommitSiblings) - PG_USLEEP(CommitDelay); + pg_usleep(CommitDelay); XLogFlush(recptr); } |