Question

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)

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top