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 1enPm4-0003V9-UP for pgsql-general@arkaria.postgresql.org; Sun, 18 Feb 2018 14:17:05 +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 1enPm3-0004hb-AB for pgsql-general@arkaria.postgresql.org; Sun, 18 Feb 2018 14:17:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1enPm2-0004hJ-SW for pgsql-general@lists.postgresql.org; Sun, 18 Feb 2018 14:17:03 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1enPlr-0002mR-NE for pgsql-general@postgresql.org; Sun, 18 Feb 2018 14:16:59 +0000 Received: by mail-wr0-x243.google.com with SMTP id z12so985171wrg.4 for ; Sun, 18 Feb 2018 06:16:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=tZ/edEpK1sjHVOlZLrFOwCU3tTg+WDHl9ouFNCmsIZM=; b=vdYOtx+QCGVOOIdrSPNpNz38UcqmrMRi0I1HtJN4PU+7jfe0HdUaT8ZjiT92Ub9xOP 2TlBvSqP9NG8f0G/mQ6JiV8xTcX1UDzuPtLnWKfKByBLhetHNB2jn0aen0TUcWF5RlX2 6rz62j8ts29ozu/TG2eDZPRwccXxT+QClYpjdnv3ZM1Istitao1Kv5ykgaWt2XeZbNKL 6b+y+tx5L76f0lt/jqr7IbM13LOy+B5c9wMwM+v7MapTsy2iYbrfWwJ1HYd5sEs3+ZVI uYA6G5eQL7cOy14DDv/67FnwQhJJm/dVUhko5vgk7PeW2rLcfoEFaiKSxtxvC5zP9zdG 4gSw== 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-language :content-transfer-encoding; bh=tZ/edEpK1sjHVOlZLrFOwCU3tTg+WDHl9ouFNCmsIZM=; b=V4tMbmtKyIskT7NmrOLmPWNEh3KfSkdowgNlM4WGEzpjEDk0pQ/OnPkRtwnwnXOHDG /TVHqhiOj9XN48+164lt06p/L9TKJ6UFrj06DYgql2XRoCbkMercRTUKlc0iEsnjjT3U 24peb17Qu4BhuACtgxU0hc38xwhKz2kMBy9Pn7JYoOjaFGNWOTHBkTx9iwmhajNfaGlV E3CKzmMDQYgXn+NIRVF/rFqn0+8VEMvw7OL9jstG+W8onwgfPHa5c1gqin0XVa9d5ioy lLSmrakpDNh4Gjz3xbH6YYQahOPlL97DtRwcqKZT1m7TLSkiPKd6VutgBi46tCs0vRy0 8HTg== X-Gm-Message-State: APf1xPB6kxTguZ8w+5n6x5wogCglsFmzTccmgpXBr/IrjD4yRUmRPVTh 524Mj3dGNAOFN9f0tiAHBRbP5l769q4EVCAtZGTZoCGxL3V0jclSEyfN0VCz6OQUTGtNHQJwxTL akxFOQ+zbeShmc9/zlVqR0wKVfXYJamstXSTFBb70sY1gWcU50XoG7JQKsHK2Mgffn+C7oZFdEj HqavLJedZV X-Google-Smtp-Source: AH8x226bPOfTthZih8xkkAkTNVGeBzLBtjfC8ApjmstUxU3As8LIJM7/lBBV1VHLduOJhPr9/+lG5Q== X-Received: by 10.223.182.71 with SMTP id i7mr9971430wre.166.1518963409899; Sun, 18 Feb 2018 06:16:49 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id 2sm14688889wmk.47.2018.02.18.06.16.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Feb 2018 06:16:49 -0800 (PST) Subject: Re: shared_buffers 8GB maximum To: Vitaliy Garnashevich , pgsql-general@postgresql.org References: <7tve8ddg1lcf4uejigos0j71kkjd488jad@4ax.com> <30ec3be0-a4b2-edb6-87f9-8874afe9d818@2ndquadrant.com> <688b6a68-bcaf-5658-8b94-fa5720c74d7c@gmail.com> From: Tomas Vondra Message-ID: <308ca303-a0c2-753c-d2d2-227db241cad7@2ndquadrant.com> Date: Sun, 18 Feb 2018 15:16:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <688b6a68-bcaf-5658-8b94-fa5720c74d7c@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 02/18/2018 02:41 PM, Vitaliy Garnashevich wrote: > >> 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? > I'm not aware of such tool. But I suppose it could be done by integrating information from pg_buffercache and pgfincore [1]. [1] https://github.com/klando/pgfincore >> 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) > It depends on how large is the active part of the data set is. If it fits into 200GB but not to smaller shared buffers (say, 100GB), then using 200GB may be a win. If the active set is much larger than RAM, smaller shared_buffer values work better in my experience. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services