2

I'm using postgreSQL 9.3 database and I have increased the shared_buffers and effective_cache_size in the settings.

Will postgreSQL always take this amount of memory or only when needed?

I'm running my database on an Amazon EC2 instance and I will monitor the memory with a CloudWatch custom metric and I'm now thinking about it if the memory I set in the configuration will always be reserved i.e. appears to be used in the cloudWatch metric.

If this is the case, how can I monitor the actual used memory of postgreSQL?

Mark Storey-Smith
31.9k9 gold badges91 silver badges125 bronze badges
asked Oct 28, 2014 at 8:54

2 Answers 2

3

shared_buffers are statically taken at startup and are never resized. effective_cache_size is just a hint to the optimizer. it is never allocated. it merely gives a hint of what is going on. so shared_buffers is what you see as taken.

answered Oct 28, 2014 at 9:20
2
  • Thank you for the answer. But it is possible for postgreSQL to go beyond the shared_buffers size, i.e. to take more memory? Commented Oct 28, 2014 at 9:21
  • well, shared_buffers are not the only memory area allocated statically. my personal rule of thumb is: shared_buffers + 10% is roughly what you see as statically allocated memory. the rest is process local memory. Commented Oct 28, 2014 at 10:02
1

shared_buffers is the statically allocated shared cache all PostgreSQL backends share.

in addition to this, each back-end has private memory which it uses for query plans, query text, prepared statements, cursors, and much more. It also has some query working memory, controlled by work_mem, which is used for in-memory sorts/joins/etc, and has maintenance_work_mem that's used for things like index builds.

PostgreSQL as a whole always uses more than shared_buffers. It has other small shared memory segments that're used for many things, as well as the per-backend working memory.

answered Oct 28, 2014 at 9:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.