- Mastering PostgreSQL 9.6
- Hans Jurgen Schonig
- 271字
- 2021-07-09 19:57:14
Configuring VACUUM and autovacuum
Back in the early days of PostgreSQL projects, people had to run VACUUM manually. Fortunately this is long gone. Nowadays administrators can rely on a tool called autovacuum, which is part of the PostgreSQL Server infrastructure. It automatically takes care of cleanup and works in the background. It wakes up once per minute (see autovacuum_naptime = 1 in postgresql.conf) and checks if there is work to do. If there is work, autovacuum will fork up to three worker processes (see autovacuum_max_workers in postgresql.conf).
The main question is: When does autovacuum trigger the creation of a worker process?
The answer to this question can again be found in postgresql.conf:
autovacuum_vacuum_threshold = 50
autovacuum_analyze_threshold = 50
autovacuum_vacuum_scale_factor = 0.2
autovacuum_analyze_scale_factor = 0.1
The autovacuum_vacuum_scale_factor tells PostgreSQL that a table is worth vacuuming if 20% of data has been changed. The trouble is that, if a table consists of one row, one change is already 100%. It makes absolutely no sense to fork a complete process to clean up just one row. Therefore autovacuum_vacuuum_threshold says that we need 20% and that 20% must be at least 50 rows. Otherwise, VACUUM won't kick in. The same mechanism is used when it comes to optimizer stats creation. 10% and at least 50 rows are needed to justify new optimizer stats. Ideally, autovacuum creates new statistics during a normal VACUUM to avoid unnecessary trips to the table.
- Word 2000、Excel 2000、PowerPoint 2000上機指導與練習
- 輕松學Java
- 影視后期制作(Avid Media Composer 5.0)
- 80x86/Pentium微型計算機原理及應用
- Grome Terrain Modeling with Ogre3D,UDK,and Unity3D
- LAMP網站開發黃金組合Linux+Apache+MySQL+PHP
- Microsoft System Center Confi guration Manager
- 云計算和大數據的應用
- 基于敏捷開發的數據結構研究
- SQL Server數據庫應用基礎(第2版)
- 網絡服務器搭建與管理
- 嵌入式Linux系統實用開發
- 伺服與運動控制系統設計
- 計算機辦公應用培訓教程
- 計算機應用基礎學習指導與練習(Windows XP+Office 2003)