// postgresql · timeouts

idle_in_transaction_session_timeout

Terminate sessions that sit idle inside an open transaction for longer than this; 0 disables.

Predeterminado
0 (disabled)
Range
0 to about 24 days, in ms
Restart needed
No
Default checked on
PostgreSQL 18

Lo que hace

An open transaction holds locks and stops VACUUM from removing rows newer than its snapshot. This ends the whole session, not just the transaction.

Valor predeterminado

0 (disabled). 0 (PostgreSQL 18).

Check the current value

SHOW idle_in_transaction_session_timeout;

SELECT setting, unit, boot_val, context, source, pending_restart
FROM pg_settings
WHERE name = 'idle_in_transaction_session_timeout';

Change it

SET idle_in_transaction_session_timeout = '5min';   -- this session
ALTER ROLE reporting SET idle_in_transaction_session_timeout = '5min';   -- new sessions of one role

ALTER SYSTEM SET idle_in_transaction_session_timeout = '5min';
SELECT pg_reload_conf();

No restart. Any role can SET it for a session or with SET LOCAL for one transaction; a server-wide ALTER SYSTEM change applies after a reload (context is user).

When to change it

On almost every application server: forgotten transactions from crashed clients or debuggers are a common cause of bloat and lock pile-ups.

What can go wrong

Clients get a terminated connection and must reconnect; pools usually handle that.

Questions about idle_in_transaction_session_timeout

What is the default value of idle_in_transaction_session_timeout in PostgreSQL?

0 (disabled). 0 (PostgreSQL 18).

Does changing idle_in_transaction_session_timeout require a restart?

No. No restart. Any role can SET it for a session or with SET LOCAL for one transaction; a server-wide ALTER SYSTEM change applies after a reload (context is user).

When should I change idle_in_transaction_session_timeout?

On almost every application server: forgotten transactions from crashed clients or debuggers are a common cause of bloat and lock pile-ups.

Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.

// one client for every engine

Check idle_in_transaction_session_timeout on your own server

SQLly runs the query above against PostgreSQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.