log_min_duration_statement

类型: integer
默认: -1 (-1)
最低限度: -1 (-1)
最大: 2147483647 (2147483647ms)
单元: milliseconds (ms)
上下文: superuser
重新开始: false

如果语句运行至少指定的时间量,将导致记录每一个这种完成的语句的持续时间。如果指定值时没有单位,则以毫秒为单位。将这个参数设置为零将打印所有语句的执行时间。 设置为 -1 (默认值)将停止记录语句持续时间。例如,如果你设置它为250ms,那么所有运行 250ms 或更久的 SQL 语句将被记录。启用这个参数可以有助于追踪应用中未优化的查询。只有超级用户可以改变这个设置。

对于使用扩展查询协议的客户端,解析、绑定和执行步骤的持续时间将被独立记录。

当把这个选项和log_statement一起使用时,已经被log_statement记录的语句文本不会在持续时间日志消息中重复。如果你没有使用syslog,我们推荐你使用log_line_prefix记录 PID 或会话 ID,这样你可以使用进程 ID 或会话 ID 把语句消息链接到后来的持续时间消息。

建议 [EN]

Possibly the most generally useful log setting for troubleshooting performance, especially on a production server. Records only long-running queries for analysis; since these are often your "problem" queries, these are the most useful ones to know about. Used for pg_fouine.

条评论