idle_session_timeout
Terminate sessions that sit idle waiting for a client query longer than this; 0 disables.
- デフォルト
0 (disabled)- Range
- 0 to about 24 days, in ms
- Restart needed
- いいえ
- Default checked on
- PostgreSQL 18
何ができるか
Unlike idle_in_transaction_session_timeout it leaves sessions parked inside an open transaction alone, and an idle session without a transaction costs the server little. Added in PostgreSQL 14.
デフォルト値
0 (disabled). 0 (PostgreSQL 18); the parameter exists from PostgreSQL 14.
Check the current value
SHOW idle_session_timeout; SELECT setting, unit, boot_val, context, source, pending_restart FROM pg_settings WHERE name = 'idle_session_timeout';
Change it
ALTER SYSTEM SET idle_session_timeout = '10min'; SELECT pg_reload_conf();
No restart: reload with SELECT pg_reload_conf() or pg_ctl reload. It cannot be changed per session (context is sighup).
When to change it
Against half-dead clients and forgotten sessions, especially where no connection pool sits in front of the application; scope it per role with ALTER ROLE rather than server-wide.
What can go wrong
It kills sessions the client still considers parked, so dashboards, schedulers or IDEs that hold a connection between jobs see it vanish with 'terminating connection due to idle-session timeout'. Sessions idle inside a transaction are exempt.
The closest setting on other engines
| エンジン | 設定 | デフォルト | Restart |
|---|---|---|---|
| PostgreSQL |
idle_session_timeout this page
|
0 (disabled) |
いいえ |
| MySQL |
net_write_timeout
|
60 |
いいえ |
| SQL Server |
remote query timeout (s)
|
600 |
いいえ |
| Oracle |
max_idle_time
|
0 (no limit) |
いいえ |
Questions about idle_session_timeout
What is the default value of idle_session_timeout in PostgreSQL?
0 (disabled). 0 (PostgreSQL 18); the parameter exists from PostgreSQL 14.
Does changing idle_session_timeout require a restart?
No. No restart: reload with SELECT pg_reload_conf() or pg_ctl reload. It cannot be changed per session (context is sighup).
When should I change idle_session_timeout?
Against half-dead clients and forgotten sessions, especially where no connection pool sits in front of the application; scope it per role with ALTER ROLE rather than server-wide.
Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.
Related on SQLly
Check idle_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.
このページのテキストとデータ: CC BY 4.0、出典は SQLly (sqlly.app) と明記してください。 コードと SQL スニペット: MIT. ライセンスの詳細