首页 > 解决方案 > 为什么在没有查询的情况下记录持续时间?

问题描述

我在 postgresql.conf 中启用了这个参数:

log_statement = 'all'
logging_collector = on
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_directory = 'pg_log'

现在我看到了:

2020-08-26 11:05:33.151 UTC [29051] postgres@mydb LOG:  duration: 134.300 ms
2020-08-26 11:05:33.475 UTC [29050] postgres@mydb LOG:  duration: 1015.984 ms
2020-08-26 11:05:33.601 UTC [29041] postgres@mydb LOG:  duration: 1149.833 ms
2020-08-26 11:05:34.815 UTC [29053] postgres@mydb LOG:  duration: 2354.413 ms
2020-08-26 11:05:39.963 UTC [29056] postgres@mydb LOG:  duration: 7495.109 ms
2020-08-26 11:05:39.971 UTC [29054] postgres@mydb LOG:  duration: 7506.584 ms
2020-08-26 11:05:39.976 UTC [29055] postgres@mydb LOG:  duration: 7514.726 ms
2020-08-26 11:05:40.101 UTC [29058] postgres@mydb LOG:  duration: 7629.628 ms
2020-08-26 11:05:40.450 UTC [29057] postgres@mydb LOG:  duration: 7973.784 ms
2020-08-26 11:05:41.293 UTC [29059] postgres@mydb LOG:  duration: 8820.805 ms

我想知道哪个查询需要这么长时间。

Postgresql 10 Ubuntu 18.04.2 LTS

标签: postgresqlpostgresql-10

解决方案


不要使用log_durationlog_statement = 'all'

log_min_duration_statement = 0

你有你想要的。


推荐阅读