1

I am tuning a PG installation with 32GB of RAM.

The question is: which one of the following sentences is true?

  1. effective_cache_size + shared_buffers ~= 30GB (PG knows that it has shared buffer plus the effective_cache_size)

  2. effective_cache_size ~= 30GB (effective_cache_size includes shared_buffers)

1

Quote from the manual

When setting this parameter you should consider both PostgreSQL's shared buffers and the portion of the kernel's disk cache that will be used for PostgreSQL data files

(emphasis mine)

So the answer is: yes, it includes the shared buffers.

If you set shared buffer to e.g. 8GB and see that the operating system uses approx 16GB for caching, effective_cache_size should be set to 24GB

Note that this parameter does not allocate any memory. It's just a hint to the optimizer how likely it is that a block needs to physically read from disk.

0

The latter choice, but only if you will have at most one large query running at a time. Each query is planned as if it will have exclusive access to that amount of cache space. If many large queries will have to share that space, then you should manually downscale the setting appropriately.

1
  • But concurrent queries will also share cached objects, so the "appropriately" in your answer is somewhat hard to gauge... Nov 9 '20 at 12:05

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.