# idle_session_timeout

> idle_session_timeout is the PostgreSQL setting that defines the maximum allowed idle time between queries, when not in a transaction.
---

> [!NOTE]
> **Fact — official short description:** “Sets the maximum allowed idle time between queries, when not in a transaction.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `integer` | Upstream pg_settings type |
| Context | `user` | Settable by an ordinary user |
| Unit | `ms` | Raw unit |
| Range | `0` – `2147483647` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Client Connection Defaults / Statement Behavior | Upstream classification |
| Latest boot value | `0` | 0 ms |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG14 |
| Present in | PG14–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`9877374bef76`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=9877374bef76ef03923f6aa8b955f2dbcbe6c2c7) — Add idle_session_timeout. |
| Commit date | 2021-01-06 |
| Discussion | [thread 1](https://postgr.es/m/763A0689-F189-459E-946F-F0EC4458980B@hotmail.com) |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG14–19 Beta 3 | `0` | `ms` | 0 ms |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

idle_session_timeout sets the maximum allowed idle time between queries, when not in a transaction. 0 disables the timeout. It closes sessions idle outside a transaction; such sessions are usually cheap, and poolers may react badly to unexpected server-side closure.

idle_session_timeout is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.

Timeouts overlap: the first applicable deadline wins, while client, pooler, TCP, and server cancellation behavior determines whether work is retried, canceled, or the session is closed.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Set idle_session_timeout from the service latency and failure budget, preferably per role or application. Test retries and cancellation paths before enforcing a cluster-wide value. |
| OLAP | Analytical work usually needs a larger or job-specific idle_session_timeout; preserve a finite guardrail for abandoned work without killing legitimate long scans. |
| Small nodes | Use a conservative finite idle_session_timeout only when the client or operating system handles termination correctly; verify that maintenance still has a dedicated exception. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | Unmodified | — | — |
| OLAP | Unmodified | — | — |
| CRIT | Unmodified | — | — |
| TINY | Unmodified | — | — |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG14–19 Beta 3 unmodified; OLAP: PG14–19 Beta 3 unmodified; CRIT: PG14–19 Beta 3 unmodified; TINY: PG14–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

## Common pitfalls {#common-pitfalls}

- Changing idle_session_timeout in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.
- Forgetting that zero usually disables the timeout or delegates behavior to the operating system.
- Setting overlapping deadlines without deciding which layer owns retries, cancellation, and connection disposal.
- Changing idle_session_timeout globally without a rollback plan and a client or operational compatibility test.

## Related parameters {#related-parameters}

[`statement_timeout`](/parameters/statement-timeout/) · [`lock_timeout`](/parameters/lock-timeout/) · [`transaction_timeout`](/parameters/transaction-timeout/) · [`idle_in_transaction_session_timeout`](/parameters/idle-in-transaction-session-timeout/) · [`deadlock_timeout`](/parameters/deadlock-timeout/)

## References {#references}

- [PostgreSQL 19 Beta 3 — idle_session_timeout](https://www.postgresql.org/docs/19/runtime-config-client.html#GUC-IDLE-SESSION-TIMEOUT)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
