idle_in_transaction_session_timeout

Type: integer
Default: 0 (0ms)
Min: 0 (0ms)
Max: 2147483647 (2147483647ms)
Unit: milliseconds (ms)
Context: user
Restart: false
Since: 9.6

Terminate any session that has been idle (that is, waiting for a client query) within an open transaction for longer than the specified amount of time. If this value is specified without units, it is taken as milliseconds. A value of zero (the default) disables the timeout.

This option can be used to ensure that idle sessions do not hold locks for an unreasonable amount of time. Even when no significant locks are held, an open transaction prevents vacuuming away recently-dead tuples that may be visible only to this transaction; so remaining idle for a long time can contribute to table bloat. See routine-vacuuming for more details.

Recommendations

Set to 1 hour maximum, or as low as 1 minute if you know your query load well. Idle transactions are bad news.

Comments