Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b9kql-000158-My for pgsql-zh-general@arkaria.postgresql.org; Mon, 06 Jun 2016 03:05:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b9kqk-00016t-Fk for pgsql-zh-general@arkaria.postgresql.org; Mon, 06 Jun 2016 03:05:10 +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 1b9kqb-0000wR-Vn for pgsql-zh-general@postgresql.org; Mon, 06 Jun 2016 03:05:02 +0000 Received: from [59.151.11.100] (helo=Exchange01.qunarservers.com) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1b9kqU-0006V9-3b for pgsql-zh-general@postgresql.org; Mon, 06 Jun 2016 03:05:00 +0000 Received: from EXCHANGE42.qunarservers.com (120.132.35.213) by EXCHANGE01.qunarservers.com (59.151.11.100) with Microsoft SMTP Server (TLS) id 14.3.224.2; Mon, 6 Jun 2016 11:04:21 +0800 Received: from [10.91.40.163] (10.91.40.163) by exchange42.qunarservers.com (10.90.4.18) with Microsoft SMTP Server (TLS) id 14.3.224.2; Mon, 6 Jun 2016 11:04:21 +0800 Message-ID: <5754E835.6040604@qunar.com> Date: Mon, 6 Jun 2016 11:04:21 +0800 From: =?UTF-8?B?5byg5paH5Y2H?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Subject: Re: =?UTF-8?B?W+WNmuaWh10g5Y+C5pWwbWF4X3dhbF9z?= =?UTF-8?B?aXpl5LiObWluX3dhbF9zaXpl55qE6K6h566X5LiO5b2x5ZON?= References: In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.91.40.163] X-Host-Lookup-Failed: Reverse DNS lookup failed for 59.151.11.100 (failed) X-Pg-Spam-Score: -1.1 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-zh-general Precedence: bulk Sender: pgsql-zh-general-owner@postgresql.org 权叔真是惜字如金啊:-) On 2016年06月04日 10:50, Quan Zongliang wrote: > 有人问我现在 checkpoint_segments 怎么计算,所以写了一篇这个分想给大家。 > 希望我拙劣的文笔能够把问题说清楚。 > > 原文链接:http://my.oschina.net/quanzl/blog/686932 > > 1、GUC参数最大最小值的设置是一个开区间,我们看实数的设置 > > if (newval->realval < conf->min || newval->realval > conf->max) > > > 2、checkpoint_completion_target 取值范围 (0.0, 1.0) > > { > {"checkpoint_completion_target", PGC_SIGHUP, WAL_CHECKPOINTS, > gettext_noop("Time spent flushing dirty buffers during > checkpoint, as fraction of checkpoint interval."), > NULL > }, > &CheckPointCompletionTarget, > 0.5, 0.0, 1.0, > NULL, NULL, NULL > }, > > > 3、新参数 min_wal_size、max_wal_size > 以前叫做 checkpoint_segments 已经消失,原意是 Maximum number of log > file segments between automatic WAL checkpoints > > > 4、max_wal_size 的定义和计算方式 > > { > {"max_wal_size", PGC_SIGHUP, WAL_CHECKPOINTS, > gettext_noop("Sets the WAL size that triggers a > checkpoint."), > NULL, > GUC_UNIT_XSEGS > }, > &max_wal_size, > 64, 2, INT_MAX, > NULL, assign_max_wal_size, NULL > }, > 公式 > > {"TB", GUC_UNIT_XSEGS, (1024 * 1024 * 1024) / (XLOG_SEG_SIZE / > 1024)}, > {"GB", GUC_UNIT_XSEGS, (1024 * 1024) / (XLOG_SEG_SIZE / 1024)}, > {"MB", GUC_UNIT_XSEGS, -(XLOG_SEG_SIZE / (1024 * 1024))}, > {"kB", GUC_UNIT_XSEGS, -(XLOG_SEG_SIZE / 1024)}, > 结合 GUC代码知道,最后得到的值已经是段数 > > > 5、每次 checkpoint 涉及的最大段数,原来是由我们通过参数来直接指定的, > 而现在 > > target = (double) max_wal_size / (2.0 + CheckPointCompletionTarget); > > /* round down */ > CheckPointSegments = (int) target; > > if (CheckPointSegments < 1) > CheckPointSegments = 1; > 我们知道 CheckPointCompletionTarget 取值范围是 (0.0, 1.0),所以最终 > CheckPointSegments得到的值范围是 max_wal_size 的 1/3 ~ 1/2,最小为1。 > > > -------------------------------------------- > 权宗亮 > > -- ---------------------- 张文升 | PostgreSQL DBA ---------------------- pg开发指南 http://wiki.corp.qunar.com/pages/viewpage.action?pageId=58058230 pg发布流程 http://wiki.corp.qunar.com/pages/viewpage.action?pageId=56215301 pg值班列表 http://wiki.corp.qunar.com/pages/viewpage.action?pageId=50508626 pg机器列表 http://wiki.corp.qunar.com/pages/viewpage.action?pageId=36438672 -- Sent via pgsql-zh-general mailing list (pgsql-zh-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-zh-general