transaction_timeout
Terminate any session whose transaction has run longer than this; 0 disables.
- 默认
0 (disabled)- Range
- 0 to about 24 days, in ms
- Restart needed
- 否
- Default checked on
- PostgreSQL 18
作用
Added in PostgreSQL 17. Covers explicit transactions and single statements outside one. Like idle_in_transaction_session_timeout, it ends the session.
默认值
0 (disabled). 0 (PostgreSQL 18); the parameter exists from PostgreSQL 17.
Check the current value
SHOW transaction_timeout; SELECT setting, unit, boot_val, context, source, pending_restart FROM pg_settings WHERE name = 'transaction_timeout';
Change it
SET transaction_timeout = '10min'; -- this session ALTER ROLE reporting SET transaction_timeout = '10min'; -- new sessions of one role ALTER SYSTEM SET transaction_timeout = '10min'; 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
For roles that should never hold a transaction open long, so their snapshots cannot block vacuum.
What can go wrong
Ends the session, so a long batch job under that role fails outright.
Questions about transaction_timeout
What is the default value of transaction_timeout in PostgreSQL?
0 (disabled). 0 (PostgreSQL 18); the parameter exists from PostgreSQL 17.
Does changing transaction_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 transaction_timeout?
For roles that should never hold a transaction open long, so their snapshots cannot block vacuum.
Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.
Related on SQLly
Check transaction_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.