I have read several articles (including Postgres docs) that suggest setting the shared_buffer's config value to 25% of your total physical memory.

Using my 4 GB memory as an example... If I understand correctly, when postgres starts up, it will request ~1 GB of physical memory from the OS. It will use this for buffering purposes. Thus, when I look at a utility like "top" I see the size/RES of the postgres process to be ~1GB.

So my question is - what happens when I have POOLED connections to Postgres? i.e. A Tomcat server which keeps N number of open, idle connections to postgres? I can see there are N number of postgress processes waiting in the background for requests from Tomcat. Each process is the same size (~1Gb). They're forks of the original process, I suppose. So does that mean Postgres as a whole is taking up N*1GB of memory?? Isn't this a bad thing to make shared_buffer this large??


No, it's still only 1GB of total memory.

The buffer is allocated as shared memory and it only allocated once, but shared between all server processes.

It's basically an "error" in the memory display of the top command, which simply reports the shared memory (that only exists once) for each process.

| improve this answer | |
  • Your last paragraph is exactly what I was thinking! - Thanks for the confirmation! – Jmoney38 Mar 1 '12 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.