Parameter · Vacuuming / Automatic Vacuuming
autovacuum_analyze_scale_factor
Number of tuple inserts, updates, or deletes prior to analyze as a fraction of reltuples.
- Default:
0.1 - Type: real
- Range: 0 … 100
- Applies: Reload
In plain words
After about 10% of a table has changed, autovacuum runs ANALYZE so the planner knows the new data distribution. On very large tables 10% can take weeks, and queries on recent data (e.g. "today's orders") get bad row estimates in the meantime.
For DBAs and operators
Compared with n_mod_since_analyze: 50 + 0.1 × reltuples by default. Typical support case: a time-series table with a monotonically increasing timestamp; queries for the newest range estimate 1 row because the histogram ends before today, causing nested-loop disasters. Fix with a smaller per-table factor (0.01–0.02) or a scheduled ANALYZE:
ALTER TABLE measurements SET (autovacuum_analyze_scale_factor = 0.01);
SELECT relname, n_mod_since_analyze, last_analyze, last_autoanalyze
FROM pg_stat_user_tables ORDER BY n_mod_since_analyze DESC;ANALYZE samples 300 × default_statistics_target rows regardless of table size, so frequent analyzes are cheap compared with vacuum.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().
See it in context
Related parameters
autovacuum_analyze_threshold autovacuum_vacuum_scale_factor default_statistics_target