文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

PostgreSQL DBA(96) - System Conf(client_min_messages)

2024-04-02 19:55

关注

PostgreSQL提供了参数client_min_messages用以控制返回给客户的消息级别,不同的级别返回的消息大小不同,默认为NOTICE。在通常情况下,如果客户端执行的SQL语句不频繁的话,使用默认参数即可,但如果客户端执行大量的SQL,设置该参数为较高级别就显得有意义了:可以减少消息的大小从而降低网络负载,提升吞吐。

参数简介
下面创建一个存储过程,raise notice显示通知信息


[local]:5432 pg12@testdb=# CREATE OR REPLACE FUNCTION foo() RETURNS void AS
pg12@testdb-# $$
pg12@testdb$#         BEGIN
pg12@testdb$#                 RAISE NOTICE 'some message';
pg12@testdb$#                 RETURN;
pg12@testdb$#         END;
pg12@testdb$# $$ LANGUAGE 'plpgsql';
CREATE FUNCTION
Time: 389.227 ms
[local]:5432 pg12@testdb=#

执行存储过程


[local]:5432 pg12@testdb=# show client_min_messages;
 client_min_messages 
---------------------
 notice
(1 row)
Time: 0.589 ms
[local]:5432 pg12@testdb=# select foo();
NOTICE:  some message
 foo 
-----
(1 row)
Time: 26.838 ms
[local]:5432 pg12@testdb=# set client_min_messages='ERROR';
SET
Time: 0.361 ms
[local]:5432 pg12@testdb=# select foo();
 foo 
-----
(1 row)
Time: 1.638 ms
[local]:5432 pg12@testdb=#

在client_min_messages设置为ERROR后,不再显示NOTICE通知信息。
下面使用benchmarksql压测工具测试该参数从NOTICE修改为ERROR后的性能变化。
1.NOTICE


[xdb@localhost run]$ ./runBenchmark.sh props.pg
2019-09-25 12:15:25,434  INFO - Term-00, 
2019-09-25 12:15:25,435  INFO - Term-00, +-------------------------------------------------------------+
2019-09-25 12:15:25,435  INFO - Term-00,      BenchmarkSQL v4.1.1
2019-09-25 12:15:25,435  INFO - Term-00, +-------------------------------------------------------------+
2019-09-25 12:15:25,435  INFO - Term-00,  (c) 2003, Raul Barbosa
2019-09-25 12:15:25,435  INFO - Term-00,  (c) 2004-2016, Denis Lussier
2019-09-25 12:15:25,435  INFO - Term-00,  (c) 2016, Jan Wieck
2019-09-25 12:15:25,435  INFO - Term-00, +-------------------------------------------------------------+
2019-09-25 12:15:25,435  INFO - Term-00, 
2019-09-25 12:15:25,435  INFO - Term-00, driver=org.postgresql.Driver
2019-09-25 12:15:25,435  INFO - Term-00, conn=jdbc:postgresql://192.168.26.28:5432/benchmarkdb
2019-09-25 12:15:25,435  INFO - Term-00, user=pg12
2019-09-25 12:15:25,435  INFO - Term-00, 
2019-09-25 12:15:25,435  INFO - Term-00, warehouses=32
2019-09-25 12:15:25,435  INFO - Term-00, terminals=20
2019-09-25 12:15:25,435  INFO - Term-00, runMins=5
2019-09-25 12:15:25,435  INFO - Term-00, limitTxnsPerMin=0
2019-09-25 12:15:25,435  INFO - Term-00, 
2019-09-25 12:15:25,435  INFO - Term-00, newOrderWeight=45
2019-09-25 12:15:25,435  INFO - Term-00, paymentWeight=43
2019-09-25 12:15:25,435  INFO - Term-00, orderStatusWeight=4       Term-00, Running Average 
2019-09-25 12:20:25,706  INFO - Term-00, 52216    Memory Usage: 26MB / 37MB                 
2019-09-25 12:20:25,706  INFO - Term-00,                                                    
2019-09-25 12:20:25,707  INFO - Term-00, Measured tpmC (NewOrders) = 7448.89                
2019-09-25 12:20:25,707  INFO - Term-00, Measured tpmTOTAL = 16626.58                       
2019-09-25 12:20:25,707  INFO - Term-00, Session Start     = 2019-09-25 12:15:25
2019-09-25 12:20:25,707  INFO - Term-00, Session End       = 2019-09-25 12:20:25
2019-09-25 12:20:25,707  INFO - Term-00, Transaction Count = 83171
[xdb@localhost run]$ 
[xdb@localhost run]$

2.ERROR


[xdb@localhost run]$ ./runBenchmark.sh props.pg
2019-09-25 12:22:57,954  INFO - Term-00, 
2019-09-25 12:22:57,954  INFO - Term-00, +-------------------------------------------------------------+
2019-09-25 12:22:57,954  INFO - Term-00,      BenchmarkSQL v4.1.1
2019-09-25 12:22:57,954  INFO - Term-00, +-------------------------------------------------------------+
2019-09-25 12:22:57,954  INFO - Term-00,  (c) 2003, Raul Barbosa
2019-09-25 12:22:57,955  INFO - Term-00,  (c) 2004-2016, Denis Lussier
2019-09-25 12:22:57,955  INFO - Term-00,  (c) 2016, Jan Wieck
2019-09-25 12:22:57,955  INFO - Term-00, +-------------------------------------------------------------+
2019-09-25 12:22:57,955  INFO - Term-00, 
2019-09-25 12:22:57,955  INFO - Term-00, driver=org.postgresql.Driver
2019-09-25 12:22:57,955  INFO - Term-00, conn=jdbc:postgresql://192.168.26.28:5432/benchmarkdb
2019-09-25 12:22:57,955  INFO - Term-00, user=pg12
2019-09-25 12:22:57,955  INFO - Term-00, 
2019-09-25 12:22:57,955  INFO - Term-00, warehouses=32
2019-09-25 12:22:57,955  INFO - Term-00, terminals=20
2019-09-25 12:22:57,955  INFO - Term-00, runMins=5
2019-09-25 12:22:57,955  INFO - Term-00, limitTxnsPerMin=0
2019-09-25 12:22:57,955  INFO - Term-00, 
2019-09-25 12:22:57,955  INFO - Term-00, newOrderWeight=45
2019-09-25 12:22:57,955  INFO - Term-00, paymentWeight=43
2019-09-25 12:22:57,955  INFO - Term-00, orderStatusWeight=4       Term-00, Running Average 
2019-09-25 12:27:58,267  INFO - Term-00, 79156    Memory Usage: 18MB / 37MB                 
2019-09-25 12:27:58,267  INFO - Term-00,                                                    
2019-09-25 12:27:58,267  INFO - Term-00, Measured tpmC (NewOrders) = 7815.72                
2019-09-25 12:27:58,267  INFO - Term-00, Measured tpmTOTAL = 17440.12                       
2019-09-25 12:27:58,267  INFO - Term-00, Session Start     = 2019-09-25 12:22:58
2019-09-25 12:27:58,267  INFO - Term-00, Session End       = 2019-09-25 12:27:58
2019-09-25 12:27:58,268  INFO - Term-00, Transaction Count = 87254
[xdb@localhost run]$

TPMC 7815 vs 7448,提升比例为4.9%

为免系统随机扰动导致的误差,重新测试了一遍


-- NONE
2019-09-25 14:53:05,384  INFO - Term-00, Measured tpmC (NewOrders) = 7168.43                
2019-09-25 14:53:05,384  INFO - Term-00, Measured tpmTOTAL = 15890.5                        
2019-09-25 14:53:05,384  INFO - Term-00, Session Start     = 2019-09-25 14:48:05
2019-09-25 14:53:05,385  INFO - Term-00, Session End       = 2019-09-25 14:53:05
2019-09-25 14:53:05,385  INFO - Term-00, Transaction Count = 79491
[xdb@localhost run]$ 
-- vacuum full;
-- client_min_messages=error
2019-09-25 14:44:29,101  INFO - Term-00, Measured tpmC (NewOrders) = 7239.02                
2019-09-25 14:44:29,101  INFO - Term-00, Measured tpmTOTAL = 16079.06                       
2019-09-25 14:44:29,101  INFO - Term-00, Session Start     = 2019-09-25 14:39:28
2019-09-25 14:44:29,102  INFO - Term-00, Session End       = 2019-09-25 14:44:29
2019-09-25 14:44:29,102  INFO - Term-00, Transaction Count = 80434
-- vacuum full;
-- update_process_title=off
-- track_activities=off
2019-09-25 15:01:11,861  INFO - Term-00, Measured tpmC (NewOrders) = 7253.43                
2019-09-25 15:01:11,861  INFO - Term-00, Measured tpmTOTAL = 16111.73                       
2019-09-25 15:01:11,862  INFO - Term-00, Session Start     = 2019-09-25 14:56:11
2019-09-25 15:01:11,862  INFO - Term-00, Session End       = 2019-09-25 15:01:11
2019-09-25 15:01:11,862  INFO - Term-00, Transaction Count = 80584
-- vacuum full;
-- client_min_messages=error
-- update_process_title=off
-- track_activities=off
2019-09-25 15:08:46,923  INFO - Term-00, Measured tpmC (NewOrders) = 7194.55                
2019-09-25 15:08:46,923  INFO - Term-00, Measured tpmTOTAL = 16059.38                       
2019-09-25 15:08:46,923  INFO - Term-00, Session Start     = 2019-09-25 15:03:46
2019-09-25 15:08:46,923  INFO - Term-00, Session End       = 2019-09-25 15:08:46
2019-09-25 15:08:46,923  INFO - Term-00, Transaction Count = 80350

似乎没有什么效果。

参考资料
Reducing log messages on the client

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 资料下载
  • 历年真题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯