pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vitaliy Garnashevich <vgarnashevich@gmail.com>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: pgsql-general@postgresql.org
Subject: Re: shared_buffers 8GB maximum
Date: Sun, 18 Feb 2018 15:41:23 +0200
Message-ID: <688b6a68-bcaf-5658-8b94-fa5720c74d7c@gmail.com> (raw)
In-Reply-To: <30ec3be0-a4b2-edb6-87f9-8874afe9d818@2ndquadrant.com>
References: <d9eeeeff-5983-0a67-9852-d6903ca2a618@gmail.com>
	<7tve8ddg1lcf4uejigos0j71kkjd488jad@4ax.com>
	<30ec3be0-a4b2-edb6-87f9-8874afe9d818@2ndquadrant.com>


> I certainly wouldn't recommend using 1/2 of RAM right away. There's a
> good chance it would be a waste of memory - for example due to double
> buffering, which effectively reduces "total" cache hit ratio.

Double buffering is often mentioned in context of tuning shared buffers. 
Is there a tool to actually measure the amount of double buffering 
happening in the system?

> Those evictions are performed either by backends or bgwriter, both of
> which are less efficient than checkpointer. Not only can checkpointer
> perform various optimizations (e.g. sorting buffers to make the writes
> more sequential), but it also writes each dirty buffer just once. With
> smaller shared_buffers the page may have be written multiple times.

In the case when shared_buffers cover most of RAM, most of writes should 
happen by checkpointer, and cache hit ratio should be high. So a 
hypothetical question: Could shared_buffers=200GB on a 250 GB RAM server 
ever be a reasonable setting? (assuming there are no other applications 
running except postgres, and 50GB is enough for allocating 
work_mem/maintenance_work_mem and for serving queries)

> The best thing you can do is set shared buffers to some conservative
> value (say, 4-8GB), let the system run for a day or two, compute the
> cache hit ratio using metrics in pg_stat_database, and then decide if
> you need to resize shared buffers.
>
> Gradual increases are a good approach in general. And yes, having
>
>      buffers_checkpoint > buffers_clean > buffers_backend
>
> is a good idea too. Together with the cache hit ratio it's probably a
> more sensible metric than looking at usagecount directly.

Thanks! While increasing shared_buffers we'll be looking at changes in 
cache hit ratio too.

Regards,
Vitaliy





view thread (11+ messages)  latest in thread

Message-ID: <688b6a68-bcaf-5658-8b94-fa5720c74d7c@gmail.com>
Permalink:  ../688b6a68-bcaf-5658-8b94-fa5720c74d7c@gmail.com/
Also on:    postgresql.org/message-id/688b6a68-bcaf-5658-8b94-fa5720c74d7c@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: vgarnashevich@gmail.com, tomas.vondra@2ndquadrant.com
  Subject: Re: shared_buffers 8GB maximum
  In-Reply-To: <688b6a68-bcaf-5658-8b94-fa5720c74d7c@gmail.com>
  References: <d9eeeeff-5983-0a67-9852-d6903ca2a618@gmail.com> <7tve8ddg1lcf4uejigos0j71kkjd488jad@4ax.com> <30ec3be0-a4b2-edb6-87f9-8874afe9d818@2ndquadrant.com> <688b6a68-bcaf-5658-8b94-fa5720c74d7c@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox