PostgreSQL DBA(66) - 配置参数(checkpoint_flush_after)

checkpoint_flush_after参数,官方解释是:

Whenever more than checkpoint_flush_after bytes have been written while performing a checkpoint, attempt to force the OS to issue these writes to the underlying storage. Doing so will limit the amount of dirty data in the kernel’s page cache, reducing the likelihood of stalls when an fsync is issued at the end of the checkpoint, or when the OS writes data back in larger batches in the background. Often that will result in greatly reduced transaction latency, but there also are some cases, especially with workloads that are bigger than shared_buffers, but smaller than the OS’s page cache, where performance might degrade. This setting may have no effect on some platforms. The valid range is between 0, which disables forced writeback, and 2MB. The default is 256kB on Linux, 0 elsewhere. (If BLCKSZ is not 8kB, the default and maximum values scale proportionally to it.) This parameter can only be set in the postgresql.conf file or on the server command line.

在CentOS 7.x下使用sysbench测试,尝试0/256kB/2MB,只有可以忽略不计的细微区别.


-------------------------------------
checkpoint_flush_after = 2MB
-------------------------------------
SQL statistics:
    queries performed:
        read:                            107367
        write:                           111268
        other:                           16840
        total:                           235475
    transactions:                        8419   (84.16 per sec.)
    queries:                             235475 (2353.96 per sec.)
    ignored errors:                      43     (0.43 per sec.)
    reconnects:                          0      (0.00 per sec.)
Throughput:
    events/s (eps):                      84.1616
    time elapsed:                        100.0337s
    total number of events:              8419
Latency (ms):
         min:                                    2.56
         avg:                                   23.76
         max:                                  311.66
         95th percentile:                       62.19
         sum:                               200002.13
Threads fairness:
    events (avg/stddev):           4209.5000/48.50
    execution time (avg/stddev):   100.0011/0.00
-------------------------------------
checkpoint_flush_after = 256kB
-------------------------------------
SQL statistics:
    queries performed:
        read:                            110021
        write:                           114168
        other:                           17072
        total:                           241261
    transactions:                        8535   (85.31 per sec.)
    queries:                             241261 (2411.50 per sec.)
    ignored errors:                      29     (0.29 per sec.)
    reconnects:                          0      (0.00 per sec.)
Throughput:
    events/s (eps):                      85.3106
    time elapsed:                        100.0462s
    total number of events:              8535
Latency (ms):
         min:                                    2.62
         avg:                                   23.43
         max:                                  260.37
         95th percentile:                       61.08
         sum:                               200017.57
Threads fairness:
    events (avg/stddev):           4267.5000/37.50
    execution time (avg/stddev):   100.0088/0.02
-------------------------------------
checkpoint_flush_after = 0
-------------------------------------
SQL statistics:
    queries performed:
        read:                            111431
        write:                           115279
        other:                           17380
        total:                           244090
    transactions:                        8689   (86.86 per sec.)
    queries:                             244090 (2440.19 per sec.)
    ignored errors:                      42     (0.42 per sec.)
    reconnects:                          0      (0.00 per sec.)
Throughput:
    events/s (eps):                      86.8646
    time elapsed:                        100.0293s
    total number of events:              8689
Latency (ms):
         min:                                    2.60
         avg:                                   23.02
         max:                                  213.39
         95th percentile:                       59.99
         sum:                               199980.96
Threads fairness:
    events (avg/stddev):           4344.5000/16.50
    execution time (avg/stddev):   99.9905/0.00

参考资料
PG doc

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/6906/viewspace-2652455/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/6906/viewspace-2652455/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PostgreSQL是一种开源的关系型数据库,它提供了多种管理工具来操作数据库,其中包括psql和pg_dump命令。 psql是一种命令行工具,可以用来与PostgreSQL数据库进行交互。它不仅能够执行SQL语句,还可以支持交互式命令。在使用psql命令时,有时需要在命令中包含密码信息。可以使用以下的方式来在命令行中带密码执行SQL语句: 1. 在命令行中输入psql命令,启动psql工具。 2. 输入连接数据库的命令,例如:psql -U username -d dbname -h hostname -p port。 3. 输入密码,此时必须在命令行中输入密码。 4. 执行SQL语句,例如:SELECT * FROM tablename; pg_dump是PostgreSQL数据库备份工具,可以用来将数据库中的数据导出到一个文件中。使用pg_dump命令时,也需要在命令行中包含密码信息。可以使用以下的方式在命令行中带密码执行pg_dump命令: 1. 在命令行中输入pg_dump命令,启动pg_dump工具。 2. 输入数据库连接信息和密码,例如:pg_dump -U username -d dbname -h hostname -p port -W。 3. 执行备份操作,例如:pg_dump -U username -d dbname -h hostname -p port -W > backup.sql。 总的来说,在使用psql和pg_dump命令时,为了在命令中包含密码信息,需要使用“-W”参数将密码输入到命令行中。当然,这种方式存在一定的安全隐患,因为密码可以被其他人看到。因此,最好使用其他方式来进行密码管理,例如使用配置文件、环境变量或者其他安全的方式。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值