mirror of
https://github.com/postgres/postgres.git
synced 2025-08-21 10:42:50 +03:00
Make large sequential scans and VACUUMs work in a limited-size "ring" of
buffers, rather than blowing out the whole shared-buffer arena. Aside from avoiding cache spoliation, this fixes the problem that VACUUM formerly tended to cause a WAL flush for every page it modified, because we had it hacked to use only a single buffer. Those flushes will now occur only once per ring-ful. The exact ring size, and the threshold for seqscans to switch into the ring usage pattern, remain under debate; but the infrastructure seems done. The key bit of infrastructure is a new optional BufferAccessStrategy object that can be passed to ReadBuffer operations; this replaces the former StrategyHintVacuum API. This patch also changes the buffer usage-count methodology a bit: we now advance usage_count when first pinning a buffer, rather than when last unpinning it. To preserve the behavior that a buffer's lifetime starts to decrease when it's released, the clock sweep code is modified to not decrement usage_count of pinned buffers. Work not done in this commit: teach GiST and GIN indexes to use the vacuum BufferAccessStrategy for vacuum-driven fetches. Original patch by Simon, reworked by Heikki and again by Tom.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.71 2007/05/17 15:28:29 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/include/commands/vacuum.h,v 1.72 2007/05/30 20:12:03 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -18,9 +18,11 @@
|
||||
#include "catalog/pg_statistic.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "storage/buf.h"
|
||||
#include "storage/lock.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
|
||||
/*----------
|
||||
* ANALYZE builds one of these structs for each attribute (column) that is
|
||||
* to be analyzed. The struct and subsidiary data are in anl_context,
|
||||
@@ -110,7 +112,8 @@ extern int vacuum_freeze_min_age;
|
||||
|
||||
|
||||
/* in commands/vacuum.c */
|
||||
extern void vacuum(VacuumStmt *vacstmt, List *relids, bool isTopLevel);
|
||||
extern void vacuum(VacuumStmt *vacstmt, List *relids,
|
||||
BufferAccessStrategy bstrategy, bool isTopLevel);
|
||||
extern void vac_open_indexes(Relation relation, LOCKMODE lockmode,
|
||||
int *nindexes, Relation **Irel);
|
||||
extern void vac_close_indexes(int nindexes, Relation *Irel, LOCKMODE lockmode);
|
||||
@@ -127,9 +130,11 @@ extern bool vac_is_partial_index(Relation indrel);
|
||||
extern void vacuum_delay_point(void);
|
||||
|
||||
/* in commands/vacuumlazy.c */
|
||||
extern void lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt);
|
||||
extern void lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
|
||||
BufferAccessStrategy bstrategy);
|
||||
|
||||
/* in commands/analyze.c */
|
||||
extern void analyze_rel(Oid relid, VacuumStmt *vacstmt);
|
||||
extern void analyze_rel(Oid relid, VacuumStmt *vacstmt,
|
||||
BufferAccessStrategy bstrategy);
|
||||
|
||||
#endif /* VACUUM_H */
|
||||
|
Reference in New Issue
Block a user