Permalink
Browse files

Selectively tune memory settings in postgresql.conf

Only tune boxes that have more than 1G RAM.
  • Loading branch information...
1 parent 89b9251 commit ef1a3330f15a32084dca2dba6d8b7ffaed87b8be @rca rca committed Mar 15, 2013
Showing with 6 additions and 0 deletions.
  1. +6 −0 files/etc/postgresql/9.2/main/postgresql.conf
@@ -110,8 +110,10 @@ ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' # (change requires rest
#------------------------------------------------------------------------------
# - Memory -
+{% if grains['mem_total'] >= 1000 %}
{% set mem = 8192 if 8192 < (grains['mem_total'] / 4) else (grains['mem_total'] / 4) %}
shared_buffers = {{ (1024 * mem)|int }}kB # min 128kB, this makes it 25% of system RAM or ceiling of 8G
+{% endif %}
# (change requires restart)
#temp_buffers = 8MB # min 800kB
#max_prepared_transactions = 0 # zero disables the feature
@@ -121,8 +123,10 @@ shared_buffers = {{ (1024 * mem)|int }}kB # min 128kB, this makes it 25% of sy
# It is not advisable to set max_prepared_transactions nonzero unless you
# actively intend to use prepared transactions.
work_mem = 64MB # min 64kB; 2-3X size of largest temp file; tune this based on "temporary file" lines in logs.
+{% if grains['mem_total'] >= 1000 %}
{% set mem = 1024 if 1024 < (grains['mem_total'] / 10) else (grains['mem_total'] / 10) %}
maintenance_work_mem = {{ (1024 * mem)|int }}kB # min 1MB, this makes it 10% of system RAM or ceiling of 1G
+{% endif %}
#max_stack_depth = 2MB # min 1MB
# - Disk -
@@ -268,8 +272,10 @@ random_page_cost = 1.1 # use 1.1 for AWS, 1.5 for Rackspace Cloud, 2.5 for bar
#cpu_tuple_cost = 0.01 # same scale as above
#cpu_index_tuple_cost = 0.005 # same scale as above
#cpu_operator_cost = 0.0025 # same scale as above
+{% if grains['mem_total'] >= 1000 %}
{% set mem = grains['mem_total'] / 2 %}
effective_cache_size = {{ (1024 * mem)|int }}kB # 50% of system memory
+{% endif %}
# - Genetic Query Optimizer -

0 comments on commit ef1a333

Please sign in to comment.