I have a standalone server which is running Jira and PostgreSQL 9.6. I have noticed that PostgreSQL has shared_buffers parameter is equal 128MB where RAM is 32GB. Because server is shared with application Jira then there is 16GB left for other usage (including postgres, httpd). According to PostgreSQL documentation size of the shared_buffers should be 25% of RAM. It could be 16GB * 0,25 = 6,5GB. Unfortunately I have doubts because application jira is using 20 connection sessions to PostgreSQL server. So I afraid that when I increase shared_buffers it will multiply it by 20 usage of entire memory.

Is it true:

approx. all memory consumed by postgres = shared_buffers*sessions

What will you suggest to do with shared_buffers parameter?

enter image description here


1 Answer 1


Yes, shared_buffer is not allocated per-session or per-user. It is shared amoung all sessions, and it is allocated only once. When parameter is not shared, it is clearly stated, i.e., on page https://www.postgresql.org/docs/9.6/runtime-config-resource.html you may see that on parameter temp_buffers description, it is stated that they are "temporary buffers used by each database session".

  • I agree with you but why top command is presenting that each session consume such amount of memory? Of course if you add all 20 sessions then it will looks like it is not possible that each session consume such amount. There will be no memory at all. I have tested it on dev env. I have increased shared_buffers to 2GB and top shows that all sessions consume 2GB each. What's the catch?
    – KUE
    Commented Feb 14, 2019 at 14:37
  • You are probably referring to the SHR column. This is memory shared among processes. It is probably the backend allocated shared memory that may be addressed by all client sessions.
    – eppesuig
    Commented Feb 14, 2019 at 14:49
  • No, column RES is my concern because it shows RAM usage. What do you think? Should I setup shared_buffer according to manual (25% of RAM)?
    – KUE
    Commented Feb 14, 2019 at 15:01
  • Yes, this is what I usually do. The shared memory is resident, of course. If you are running on linux, check shared memory kernel parameters. Since you want to use a few gigabytes, I suggest to use huge_pages, as well.
    – eppesuig
    Commented Feb 14, 2019 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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