Take the 2-minute tour ×

I know that with postgresql.conf I can limit the memory usage of specific parts of PostgreSQL, like shared memory or worker memory, but is there a way to limit the total memory usage of the PostgreSQL server? I failed to find a configuration property that does that...

BTW, I'm going to need to run it on a Windows Server 2008 machine.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

What do you mean "total" memory? It's the sum of what you allocate to the various pools.

So, in short... don't set the various pools/buffers too big and that's your total memory limit.

share|improve this answer
I see... I was hoping there is some limit I could set and rest assured that PostgreSQL will never pass it, but I guess that will have to do. Are there any pitfalls I should watch out for when setting those memory limits? –  Idan Arye Feb 25 '13 at 23:13
work_mem is max memory usable by an individual sort or other memory intensive operation (hash ops etc). Each query can have o, 1, or more of these ops. Assuming your average query has 2 or fewer sorts etc you can get a gross idea of max memory a heavily used machine might see is max_connections * work_mem * 2, give or take. Individual postgresql backends only use about 6MB so unless you have a very high max_connections individual backends, without sorts etc, don't add up to much. –  Scott Marlowe Feb 26 '13 at 8:02
Be aware that less is sometimes more, so don't just blindly increase all those numbers, as many are actually performance penalties if set to excessive levels. –  Tyler Eaves Feb 26 '13 at 15:21
add comment

Your Answer


