在配置文件中
[root@s101 /var/lib/pgsql/13/data]#nano postgresql.conf
# AUTOVACUUM #------------------------------------------------------------------------------ #autovacuum = on # Enable autovacuum subprocess? 'on' # requires track_counts to also be on. #log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and # their durations, > 0 logs only # actions running at least this number # of milliseconds. #autovacuum_max_workers = 3 # max number of autovacuum subprocesses # (change requires restart) #autovacuum_naptime = 1min # time between autovacuum runs #autovacuum_vacuum_threshold = 50 # min number of row updates before # vacuum #autovacuum_vacuum_insert_threshold = 1000 # min number of row inserts # before vacuum; -1 disables insert # vacuums #autovacuum_analyze_threshold = 50 # min number of row updates before # analyze #autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum #autovacuum_vacuum_insert_scale_factor = 0.2 # fraction of inserts over table # size before insert vacuum #autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze #autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum # (change requires restart) #autovacuum_multixact_freeze_max_age = 400000000 # maximum multixact age # before forced vacuum # (change requires restart) #autovacuum_vacuum_cost_delay = 2ms # default vacuum cost delay for # autovacuum, in milliseconds; # -1 means use vacuum_cost_delay #autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for # autovacuum, -1 means use # vacuum_cost_limit
关注表的膨胀率 select schemaname||'.'||relname, n_dead_tup, n_live_tup, coalesce(round(n_dead_tup * 100 / (case when n_live_tup + n_dead_tup = 0 then null else n_live_tup + n_dead_tup end ),2),0.00) as dead_tup_ratio from pg_stat_all_tables where 1=1 and n_dead_tup >= 10 order by dead_tup_ratio desc limit 10
查看这个表的死亡tuple 、 现存tuple、del_tuple 以及 最新一次 自动vacuum时间
select * from pg_stat_all_tables where schemaname||'.'||relname = 'myschema.o_ls_test'
参考博客
https://www.jianshu.com/p/9a34b9610012
https://www.cnblogs.com/ctypyb2002/p/9792874.html
标签:autovacuum,tup,dead,PGSQL,cost,pg,vacuum,before From: https://www.cnblogs.com/ataoxz/p/18417889