Created
September 11, 2014 15:59
-
-
Save netman92/7bac91d5916837ff9c5f to your computer and use it in GitHub Desktop.
Compute Postgres config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
ram = raw_input("Ram? [GB] ") or 8 | |
connections = raw_input("Number of expected sim. connections? ") or 1000 | |
ram = float(ram) | |
connections = int(connections) | |
shared_buffers = "%0.0fMB" % ((ram*1024)/4) | |
work_mem = "%0.0fMB" % (((ram*1024)/2)/(connections/10)) if ((ram*1024)*0.05) <= 512 else "512MB" | |
maintenance_work_mem = "%0.0fMB" % ((ram*1024)*0.05) if ((ram*1024)*0.05) <= 512 else "512MB" | |
wal_buffers = "1MB" | |
effective_cache_size = "%0.0fMB" % ((ram*1024)*0.6) | |
print "#### Generated for %0.0fGB RAM and %d connections" % (ram, connections) | |
print "\n#---------------MEMORY" | |
print "shared_buffers = " + shared_buffers | |
print "work_mem = " + work_mem | |
print "maintenance_work_mem = " + maintenance_work_mem | |
print "wal_buffers = " + wal_buffers | |
print "effective_cache_size = " + effective_cache_size | |
print "\n#---------------CHECKPOINT" | |
print "checkpoint_segments = 30" | |
print "checkpoint_completion_target = 0.7" | |
print "checkpoint_timeout = 10min" | |
print "synchronous_commit = off" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment