尽管记录了持续时间,Postgres仍未记录所有查询

时间:2015-04-24 20:38:41

标签: postgresql postgresql-9.3

我试图让我的postgresql 9.3服务器记录运行时间超过1秒的所有sql。我已经设定了:

log_min_duration=1s
log_statement='mod'
log_duration=off

对于大多数查询,日志记录工作正常,但有些语句,例如" CREATE TABLE AS"或" INSERT"没有记录声明。记录持续时间,但不是完整的sql。

之前有没有其他人见过这类问题,或者知道为什么postgres可能没有记录sql? (可能是一个交易块?)非常感谢任何帮助,谢谢。

1 个答案:

答案 0 :(得分:1)

The correct parameter is log_min_duration_statement and not log_min_duration.

And this note, from docs,

Note: When using this option together with log_statement, the text of statements that are logged because of log_statement will not be repeated in the duration log message. If you are not using syslog, it is recommended that you log the PID or session ID using log_line_prefix so that you can link the statement message to the later duration message using the process ID or session ID.

consider is a good explanation for problem.