为什么不查询就记录持续时间?
Why log duration without query?
我在 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
不要使用 log_duration
和 log_statement = 'all'
。
设置
log_min_duration_statement = 0
而且你已经得到了你想要的。
我在 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
不要使用 log_duration
和 log_statement = 'all'
。
设置
log_min_duration_statement = 0
而且你已经得到了你想要的。