Commit 7024938d7e0ba2c66653b87d9866a3a8710b2a4a
1 parent
cb376e37
Exists in
performance
PostgreSQL: put system RAM to good use
Showing
1 changed file
with
11 additions
and
3 deletions
Show diff stats
cookbooks/postgresql/templates/centos/postgresql.conf.erb
1 | listen_addresses = 'localhost,<%= node['peers']['database'] %>' | 1 | listen_addresses = 'localhost,<%= node['peers']['database'] %>' |
2 | 2 | ||
3 | -# TODO optimize these settings | 3 | +<% ram = `awk '{ if ($1 == "MemTotal:") {print($2) } }' /proc/meminfo`.to_i %> |
4 | 4 | ||
5 | -max_connections = 100 # (change requires restart) | ||
6 | -shared_buffers = 32MB # min 128kB | 5 | +####################################################################### |
6 | +# performance optimization settings | ||
7 | +####################################################################### | ||
8 | +shared_buffers = <%= (0.1 * ram).to_i %>kB # 10% of RAM for shared buffers | ||
9 | +effective_cache_size = <%= (0.8 * ram).to_i %>kB # 80% of RAM for cache | ||
10 | + | ||
11 | +####################################################################### | ||
12 | +# other settings | ||
13 | +####################################################################### | ||
14 | +max_connections = 500 # (change requires restart) | ||
7 | logging_collector = on # Enable capturing of stderr and csvlog | 15 | logging_collector = on # Enable capturing of stderr and csvlog |
8 | log_filename = 'postgresql-%a.log' # log file name pattern, | 16 | log_filename = 'postgresql-%a.log' # log file name pattern, |
9 | log_truncate_on_rotation = on # If on, an existing log file with the | 17 | log_truncate_on_rotation = on # If on, an existing log file with the |