summaryrefslogtreecommitdiff
path: root/src/backend/commands/vacuumlazy.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-09-02 19:02:20 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-09-02 19:02:20 +0000
commit35e9b1cc1ee296959d52383455052cb3743af478 (patch)
tree760d8047d591cd1e96316b3a9c12764a12dc6ae3 /src/backend/commands/vacuumlazy.c
parent962a4bb69f1dd70f1212e27ba2de7634cf91a80d (diff)
downloadpostgresql-35e9b1cc1ee296959d52383455052cb3743af478.tar.gz
Clean up a couple of ad-hoc computations of the maximum number of tuples
on a page, as suggested by ITAGAKI Takahiro. Also, change a few places that were using some other estimates of max-items-per-page to consistently use MaxOffsetNumber. This is conservatively large --- we could have used the new MaxHeapTuplesPerPage macro, or a similar one for index tuples --- but those places are simply declaring a fixed-size buffer and assuming it will work, rather than actively testing for overrun. It seems safer to size these buffers in a way that can't overflow even if the page is corrupt.
Diffstat (limited to 'src/backend/commands/vacuumlazy.c')
-rw-r--r--src/backend/commands/vacuumlazy.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c
index bfdf4b6cbb..f324b72673 100644
--- a/src/backend/commands/vacuumlazy.c
+++ b/src/backend/commands/vacuumlazy.c
@@ -31,7 +31,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.57 2005/08/20 23:26:13 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.58 2005/09/02 19:02:20 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -60,9 +60,6 @@
#define REL_TRUNCATE_MINIMUM 1000
#define REL_TRUNCATE_FRACTION 16
-/* MAX_TUPLES_PER_PAGE can be a conservative upper limit */
-#define MAX_TUPLES_PER_PAGE ((int) (BLCKSZ / sizeof(HeapTupleHeaderData)))
-
typedef struct LVRelStats
{
@@ -259,7 +256,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
* dead-tuple TIDs, pause and do a cycle of vacuuming before we
* tackle this page.
*/
- if ((vacrelstats->max_dead_tuples - vacrelstats->num_dead_tuples) < MAX_TUPLES_PER_PAGE &&
+ if ((vacrelstats->max_dead_tuples - vacrelstats->num_dead_tuples) < MaxHeapTuplesPerPage &&
vacrelstats->num_dead_tuples > 0)
{
/* Remove index entries */
@@ -554,7 +551,7 @@ static int
lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer,
int tupindex, LVRelStats *vacrelstats)
{
- OffsetNumber unused[BLCKSZ / sizeof(OffsetNumber)];
+ OffsetNumber unused[MaxOffsetNumber];
int uncnt;
Page page = BufferGetPage(buffer);
ItemId itemid;
@@ -960,7 +957,7 @@ lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks)
maxtuples = (maintenance_work_mem * 1024L) / sizeof(ItemPointerData);
maxtuples = Min(maxtuples, INT_MAX);
/* stay sane if small maintenance_work_mem */
- maxtuples = Max(maxtuples, MAX_TUPLES_PER_PAGE);
+ maxtuples = Max(maxtuples, MaxHeapTuplesPerPage);
vacrelstats->num_dead_tuples = 0;
vacrelstats->max_dead_tuples = (int) maxtuples;