Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1enPDm-0000rz-E8 for pgsql-general@arkaria.postgresql.org; Sun, 18 Feb 2018 13:41:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1enPDk-0005Ya-8D for pgsql-general@arkaria.postgresql.org; Sun, 18 Feb 2018 13:41:36 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1enPDj-0005YQ-QA for pgsql-general@lists.postgresql.org; Sun, 18 Feb 2018 13:41:36 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1enPDc-0002yY-84 for pgsql-general@postgresql.org; Sun, 18 Feb 2018 13:41:34 +0000 Received: by mail-lf0-x243.google.com with SMTP id j193so9752739lfe.0 for ; Sun, 18 Feb 2018 05:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=XVYnnj7viUillpHVOxcqnvCnApDhZ+Pgg4BjVYWO82s=; b=Npmv4tIoeTYw6KQUzptUsAOXQ0/1x881FIjAN4PCtQuaRLcBWXTdOwJd8EMbnLg0tA h0dotTearBiiVDZNOvQfBd2q8gHmTWtbaypoU/+sbjYTsEtjSTULFCJH9R7LHoflkQXJ lLQdW4Fp70bWDiT8nZcz4lwZFa7GHGQQRidNPP5q7H1vRmnzMVQit2rtipDCvv4FQ9aJ bJ4VtRGh6vFTLdZ9Wt1/Y1EHS59J4hGe+9UVWIFpzwRq/0GlW58udUOujg59TM0jjtR1 1IXM015/SxCqu2rbhv66kxZUrdxhQCtiYcK0JasSk54CAj5nWku9cqQvVIjoYS+X29SS I1xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=XVYnnj7viUillpHVOxcqnvCnApDhZ+Pgg4BjVYWO82s=; b=mHzWXNL37bYUHOr6t9buFLZEh0BqwtgQ930y8HAtLoNJOgZCRAjCUKdc3g8AsgzGmq YYF9oz0j6zuKuEvYjCLAHt4IemFA7sXyStlYOC5C3WNpw0ZVYkbHFncTAccWv+kf1+X1 +pIX7An04O4dm79rGdTvThqKQICL6MVhSYnTwuE2h5uVVr72uf9E1qd7FwQluHW/1FPW v4AP7n91JbnE75ffbxR4AqlXgz9/LZZ7fDvUxu7Sz3HExcUHXihbDGVqEKFwFss2w7u6 EUf7PRF0dL7p+ZqznqSsm4XtRqrVSXlSdWDy6U2mOkpoD9kXNyUVIIEVRTYGEqiPW+i0 Joyg== X-Gm-Message-State: APf1xPDTkdoJPYFI18L2D8qG5ZGJKaMlfSKYxsCcPonY2o7PkGf56keN U+0v7oXoEho4nSI5x/q/nBSLLp5b X-Google-Smtp-Source: AH8x224/i2L6BKmtG/daYSzAjQhWnsWviboNWMDcbFzvIOCtnzYF3a0VqfyFYo42bAweEkPB6twc7Q== X-Received: by 10.25.113.14 with SMTP id m14mr1209547lfc.71.1518961284301; Sun, 18 Feb 2018 05:41:24 -0800 (PST) Received: from [192.168.1.151] ([178.54.41.83]) by smtp.gmail.com with ESMTPSA id b27sm3213593ljb.84.2018.02.18.05.41.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Feb 2018 05:41:23 -0800 (PST) Subject: Re: shared_buffers 8GB maximum To: Tomas Vondra , pgsql-general@postgresql.org References: <7tve8ddg1lcf4uejigos0j71kkjd488jad@4ax.com> <30ec3be0-a4b2-edb6-87f9-8874afe9d818@2ndquadrant.com> From: Vitaliy Garnashevich Message-ID: <688b6a68-bcaf-5658-8b94-fa5720c74d7c@gmail.com> Date: Sun, 18 Feb 2018 15:41:23 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <30ec3be0-a4b2-edb6-87f9-8874afe9d818@2ndquadrant.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > 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