I want to make sure Postgresql can take advantage of all available memory for caching on a dedicated DB server. How do I make sure that the kernel's shared memory settings are correct? Does anyone know the calculation to make sure shmax etc. won't limit Postgresql?
Here's a little snippet that allows the server to use up to half of physical RAM for shared memory:
Put the output of that into /etc/sysctl.conf and run:
Then you're set.
PostgreSQL uses the operating system to supplement all of its read and writes, so you really don't want to dedicate half of RAM--this has plenty of margin in it for a dedicated database server. Tests varying the amount of dedicated RAM for the server normally find maximum throughput somewhere between 15% and 40% of total RAM; any more and you end up with too many double buffered pages. And the useful upper limit is around 8GB on large systems, period, due to as yet unresolved caching contention issues in the server code. More on server tuning at the PostgreSQL wiki.