1
votes

We are using postgres 9.2 version on Centos operating system. We have around 1300+ tables.We have following auto vacuum settings are enables. Still few of the tables(84 tables) which are always busy are not vacuumed.Dead tuples in those tables are more than 5000. Due to that tables are bloating and observed few areas has performance degradation.

autovacuum = on                             
log_autovacuum_min_duration = 100       
autovacuum_max_workers = 5  
autovacuum_naptime = 1min  
autovacuum_vacuum_threshold = 40                        
autovacuum_analyze_threshold = 20                       
autovacuum_vacuum_scale_factor = 0.1    
autovacuum_analyze_scale_factor = 0.05  
autovacuum_freeze_max_age = 200000000                       
autovacuum_vacuum_cost_delay = 30ms                     
autovacuum_vacuum_cost_limit = 1200     

# - Cost-Based Vacuum Delay -

#vacuum_cost_delay = 0ms        # 0-100 milliseconds
#vacuum_cost_page_hit = 1       # 0-10000 credits
#vacuum_cost_page_miss = 10     # 0-10000 credits
#vacuum_cost_page_dirty = 20    # 0-10000 credits
vacuum_cost_limit = 200         # 1-10000 credits   

In order to avoid the table bloating and performance degradation,we would like to set the ' autovacuum_vacuum_scale_factor'(zero) and 'autovacuum_vacuum_threshold ' (200) settings for the busy tables as below. Please let me know is there any adverse effect on DB if I set autovacuum scale factor to zero for certain tables. If yes, what is the effect and how to test.

ALTER TABLE cmdevice SET (autovacuum_vacuum_scale_factor = 0, autovacuum_vacuum_threshold = 200);

Kindly let me know the role of autovacuum_vacuum_cost_delay and autovacuum_vacuum_cost_limit settings .

1

1 Answers

1
votes

That measure will not be effective. While it will cause autovacuum to run on the table all the time, it will not make it faster.

First try to raise autovacuum_vacuum_cost_limit which determines after how much work autovacuum will “take a nap” to 2000 or so.

If that does not do the trick, lower autovacuum_vacuum_cost_delay which specifies the duration of that nap to 0. That's the best you can do.

You can change the settings on only the tables with high activity using ALTER TABLE ... SET (...).