赞
踩
有时为了定位PG数据库(postgresql)的性能问题,需要打印慢日志信息来分析,以下为开启慢日志具体方法:
在postgresql.conf文件中,增加以下配置信息,并重启pg数据库:
- log_destination = 'csvlog'
- logging_collector = on
- log_directory = 'pg_log'
- log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
- log_rotation_age = 1d
- log_rotation_size = 100MB
- log_min_messages = info
-
- # 记录执行慢的SQL
- log_min_duration_statement = 60
- log_checkpoints = on
- log_connections = on
- log_disconnections = on
- log_duration = on
- log_line_prefix = '%m'
-
-
- # 监控数据库中长时间的锁
- log_lock_waits = on
- # 记录DDL操作
- log_statement = 'ddl'
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。