Type: | integer |
Default: | 0 (0ms) |
Min: | 0 (0ms) |
Max: | 2147483647 (2147483647ms) |
Unit: | milliseconds (ms) |
Context: | user |
Restart: | false |
Abort any statement that takes more than the specified amount of time. If log_min_error_statement is set to ERROR
or lower, the statement that timed out will also be logged. If this value is specified without units, it is taken as milliseconds. A value of zero (the default) disables the timeout.
The timeout is measured from the time a command arrives at the server until it is completed by the server. If multiple SQL statements appear in a single simple-Query message, the timeout is applied to each statement separately. (PostgreSQL versions before 13 usually treated the timeout as applying to the whole query string.) In extended query protocol, the timeout starts running when any query-related message (Parse, Bind, Execute, Describe) arrives, and it is canceled by completion of an Execute or Sync message.
Setting statement_timeout
in postgresql.conf is not recommended because it would affect all sessions.
Recommendations
On StackOverflow
On pgsql-hackers
- Re: Throttling WAL inserts when the standby falls behind more than the configured replica_lag_in_bytes
- A proposal to provide a timeout option for CREATE_REPLICATION_SLOT/pg_create_logical_replication_slot
- Re: [Proposal] Add foreign-server health checks infrastructure
- Re: Autovacuum and idle_session_timeout
- statement_timeout vs DECLARE CURSOR