Type: | integer |
Default: | -1 (-1) |
Min: | -1 (-1) |
Max: | 2147483647 (2147483647ms) |
Unit: | milliseconds (ms) |
Context: | superuser |
Restart: | false |
Causes the duration of each completed statement to be logged if the statement ran for at least the specified amount of time. 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. If this value is specified without units, it is taken as milliseconds. Setting this to zero prints all statement durations. -1
(the default) disables logging statement durations. Only superusers and users with the appropriate SET
privilege can change this setting.
This overrides log_min_duration_sample, meaning that queries with duration exceeding this setting are not subject to sampling and are always logged.
For clients using extended query protocol, durations of the Parse, Bind, and Execute steps are logged independently.
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.
Recommendations
On StackOverflow
On pgsql-hackers
- Re: filesystem full during vacuum - space recovery issues
- Re: Send duration output to separate log files
- Re: Fix log_line_prefix to display the transaction id (%x) for statements not in a transaction block
- Re: Add a warning message when using unencrypted passwords
- Send duration output to separate log files