# idle_in_transaction_session_timeout

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

> [!NOTE]
> **Fact — official short description:** “Sets the maximum allowed idle time between queries, when 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 | PG9.6 |
| Present in | PG9.6–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`c6dda1f48e57`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=c6dda1f48e573cc60fe25d8d470a05bfabed0252) — Add idle_in_transaction_session_timeout. |
| Commit date | 2016-03-16 |
| Discussion | — |

## Default history {#default-history}

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

## How it works {#mechanism}

idle_in_transaction_session_timeout sets the maximum allowed idle time between queries, when in a transaction. 0 disables the timeout. It terminates sessions idle inside an open transaction, releasing locks and old snapshots that can block vacuum cleanup and cause bloat.

idle_in_transaction_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_in_transaction_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_in_transaction_session_timeout; preserve a finite guardrail for abandoned work without killing legitimate long scans. |
| Small nodes | Use a conservative finite idle_in_transaction_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 | `10min` | different | `10min` |
| OLAP | `0` | same as boot | `0` |
| CRIT | `1min` | different | `1min` |
| TINY | `10min` | different | `10min` |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.6–19 Beta 3 = 10min (dcs); OLAP: PG9.6–19 Beta 3 = 0 (dcs); CRIT: PG9.6–19 Beta 3 = 1min (dcs); TINY: PG9.6–19 Beta 3 = 10min (dcs). Advice, pending human review — Editorial inference: The templates bound abandoned open transactions, use a stricter limit for CRIT, and leave OLAP unlimited for deliberately long analytical transactions; each workload still needs pooler and retry review.

## Common pitfalls {#common-pitfalls}

- Changing idle_in_transaction_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_in_transaction_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_session_timeout`](/parameters/idle-session-timeout/) · [`deadlock_timeout`](/parameters/deadlock-timeout/)

## References {#references}

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