mirror of
https://github.com/postgres/postgres.git
synced 2025-12-04 12:02:48 +03:00
Add VACUUM/ANALYZE BUFFER_USAGE_LIMIT option
Add new options to the VACUUM and ANALYZE commands called BUFFER_USAGE_LIMIT to allow users more control over how large to make the buffer access strategy that is used to limit the usage of buffers in shared buffers. Larger rings can allow VACUUM to run more quickly but have the drawback of VACUUM possibly evicting more buffers from shared buffers that might be useful for other queries running on the database. Here we also add a new GUC named vacuum_buffer_usage_limit which controls how large to make the access strategy when it's not specified in the VACUUM/ANALYZE command. This defaults to 256KB, which is the same size as the access strategy was prior to this change. This setting also controls how large to make the buffer access strategy for autovacuum. Per idea by Andres Freund. Author: Melanie Plageman Reviewed-by: David Rowley Reviewed-by: Andres Freund Reviewed-by: Justin Pryzby Reviewed-by: Bharath Rupireddy Discussion: https://postgr.es/m/20230111182720.ejifsclfwymw2reb@awork3.anarazel.de
This commit is contained in:
@@ -2349,11 +2349,21 @@ do_autovacuum(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a buffer access strategy object for VACUUM to use. We want to
|
||||
* use the same one across all the vacuum operations we perform, since the
|
||||
* point is for VACUUM not to blow out the shared cache.
|
||||
* Optionally, create a buffer access strategy object for VACUUM to use.
|
||||
* We use the same BufferAccessStrategy object for all tables VACUUMed by
|
||||
* this worker to prevent autovacuum from blowing out shared buffers.
|
||||
*
|
||||
* VacuumBufferUsageLimit being set to 0 results in
|
||||
* GetAccessStrategyWithSize returning NULL, effectively meaning we can
|
||||
* use up to all of shared buffers.
|
||||
*
|
||||
* If we later enter failsafe mode on any of the tables being vacuumed, we
|
||||
* will cease use of the BufferAccessStrategy only for that table.
|
||||
*
|
||||
* XXX should we consider adding code to adjust the size of this if
|
||||
* VacuumBufferUsageLimit changes?
|
||||
*/
|
||||
bstrategy = GetAccessStrategy(BAS_VACUUM);
|
||||
bstrategy = GetAccessStrategyWithSize(BAS_VACUUM, VacuumBufferUsageLimit);
|
||||
|
||||
/*
|
||||
* create a memory context to act as fake PortalContext, so that the
|
||||
|
||||
Reference in New Issue
Block a user