agora inbox for pgsql-zh-general@postgresql.org
help / color / mirror / Atom feedFrom: 张文升 <wensheng.zhang@qunar.com>
To: pgsql-zh-general@postgresql.org
Subject: Re: [博文] 参数max_wal_size与min_wal_size的计算与影响
Date: Mon, 6 Jun 2016 11:04:21 +0800
Message-ID: <5754E835.6040604@qunar.com> (raw)
In-Reply-To: <e0990ee6-6efa-8ca0-4bdc-9052add439e7@postgresdata.com>
References: <e0990ee6-6efa-8ca0-4bdc-9052add439e7@postgresdata.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-zh-general>
权叔真是惜字如金啊:-)
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
view thread (2+ messages)
Message-ID: <5754E835.6040604@qunar.com>
Permalink: ../5754E835.6040604@qunar.com/
Also on: postgresql.org/message-id/5754E835.6040604@qunar.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 using the --to and --cc options:
reply via email
To: pgsql-zh-general@postgresql.org
Cc: wensheng.zhang@qunar.com
Subject: Re: [博文] 参数max_wal_size与min_wal_size的计算与影响
In-Reply-To: <5754E835.6040604@qunar.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox