根据我的PostgreSQL设置,我只希望语句在运行超过50毫秒时才能打印出来。但是,根据持续时间日志,这些语句的运行时间要短得多。
在我看到的一个例子中,我看到了相同事务的3个不同的持续时间日志(我猜它们对应于Parse,Bind和Execute步骤),总共约35ms。但是,无论如何,SQL查询仍然打印出来。
为什么这里不匹配?我是否以某种方式误读了日志?
Postgresql文档:
log_min_duration_statement (integer)
Causes the duration of each completed statement to be logged if the statement ran for at least the specified number of milliseconds. Setting this to zero prints all statement durations. Minus-one (the default) disables logging statement durations. For example, if you set it to 250ms then all SQL statements that run 250ms or longer will be logged. Enabling this parameter can be helpful in tracking down unoptimized queries in your applications. Only superusers can change this setting.
log_duration (boolean)
Causes the duration of every completed statement to be logged. The default is off. Only superusers can change this setting.
For clients using extended query protocol, durations of the Parse, Bind, and Execute steps are logged independently.
我的设置:
log_min_duration_statement 50
log_statement all
log_duration 1
记录一个事务(查找附近具有8603 id的所有行。我确实看到8603和47611 ID在很长一段时间内被多次重复使用。这会导致某种形式的持续时间值冲突吗?)
2015-12-08 04:30:19 UTC:ec2-54-146-195-57.compute-1.amazonaws.com(47611):xxxx@xxxx:[8603]:LOG: duration: 4.637 ms
2015-12-08 04:30:19 UTC:ec2-54-146-195-57.compute-1.amazonaws.com(47611):xxxx@xxxx:[8603]:LOG: duration: 22.992 ms
2015-12-08 04:30:19 UTC:ec2-54-146-195-57.compute-1.amazonaws.com(47611):xxxx@xxxx:[8603]:LOG: execute <unnamed>: select * ...
2015-12-08 04:30:19 UTC:ec2-54-146-195-57.compute-1.amazonaws.com(47611):xxxx@xxxx:[8603]:DETAIL: parameters: ...
2015-12-08 04:30:19 UTC:ec2-54-146-195-57.compute-1.amazonaws.com(47611):xxxx@xxxx:[8603]:LOG: duration: 7.875 ms