pg.ddx.io  pgsql-zh-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[博文] 参数max_wal_size与min_wal_size的计算与影响
2+ messages / 2 participants
[nested] [flat]

* [博文] 参数max_wal_size与min_wal_size的计算与影响
@ 2016-06-04 02:50 Quan Zongliang <zongliang.quan@postgresdata.com>
  2016-06-06 03:04 ` Re: [博文] 参数max_wal_size与min_wal_size的计算与影响 张文升 <wensheng.zhang@qunar.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Quan Zongliang @ 2016-06-04 02:50 UTC (permalink / raw)
  To: pgsql-zh-general

有人问我现在 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。


--------------------------------------------
权宗亮


-- 
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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [博文] 参数max_wal_size与min_wal_size的计算与影响
  2016-06-04 02:50 [博文] 参数max_wal_size与min_wal_size的计算与影响 Quan Zongliang <zongliang.quan@postgresdata.com>
@ 2016-06-06 03:04 ` 张文升 <wensheng.zhang@qunar.com>
  0 siblings, 0 replies; 2+ messages in thread

From: 张文升 @ 2016-06-06 03:04 UTC (permalink / raw)
  To: pgsql-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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2016-06-06 03:04 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-06-04 02:50 [博文] 参数max_wal_size与min_wal_size的计算与影响 Quan Zongliang <zongliang.quan@postgresdata.com>
2016-06-06 03:04 ` 张文升 <wensheng.zhang@qunar.com>

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