Skip to content

max_prepared_transactions

max_prepared_transactions — Sets the maximum number of simultaneously prepared transactions. Observed in PG9.0–19 Beta 3; its last measured boot default is 0 in PG19 Beta 3, with postmaster context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA.
Note

Fact — official short description: “Sets the maximum number of simultaneously prepared transactions.”

Identity

Type , Valueinteger
Upstream pg_settings type
Context , Valuepostmaster
Requires a server restart
Unit , Value
Raw unit
Range , Value0262143
Raw limits in the last observed version
Enum values , Value
— for non-enum types
Category , ValueResource Usage / Memory
Upstream classification
Latest boot value , Value0
0

Lifecycle

Fact Value
First observed PG9.0 (research boundary)
Present in PG9.0–19 Beta 3
Removed in No
Introduction commit Not asserted: predates the PG9.0 research boundary
Commit date
Discussion

Default history

Measured PG9.0–19 Beta 3 boot defaults
Versions Raw boot_val Unit Human value
PG9.0–19 Beta 3 0 0

How it works

max_prepared_transactions reserves capacity for two-phase transactions left in the prepared state by PREPARE TRANSACTION. Zero disables creating prepared transactions.

Prepared transactions retain locks and transaction state across client disconnects and crashes until COMMIT PREPARED or ROLLBACK PREPARED. Capacity requires shared memory and durable state.

A standby must configure at least the primary’s value or read queries can be refused. This is unrelated to SQL prepared statements and should remain zero unless a two-phase commit coordinator is operationally managed. Its postmaster context fixes the value at server start; changing it requires a restart.

Tuning advice

Tip

Advice. These are workload-specific starting points and must be validated with measurements.

Workload Guidance
OLTP Keep max_prepared_transactions=0 unless a real two-phase-commit coordinator monitors and resolves every prepared transaction. If enabled, size primary and standbys consistently and alert on transaction age.
OLAP Analytical workload does not justify max_prepared_transactions. Enable only for an application protocol that requires durable prepared transactions, not for SQL prepared statements.
Small nodes Leave max_prepared_transactions=0 on a small deployment unless two-phase commit is mandatory and operational recovery is documented; stranded prepared transactions can block the cluster.

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 0 same as boot {{ pg_max_prepared_transactions }}
OLAP 0 same as boot {{ pg_max_prepared_transactions }}
CRIT 0 same as boot {{ pg_max_prepared_transactions }}
TINY 0 same as boot {{ pg_max_prepared_transactions }}
Caution

Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 = 0 (dcs); OLAP: PG9.0–19 Beta 3 = 0 (dcs); CRIT: PG9.0–19 Beta 3 = 0 (dcs); TINY: PG9.0–19 Beta 3 = 0 (dcs). Advice, pending human review — Editorial inference, pending maintainer review: The explicit zero keeps two-phase prepared transactions disabled unless the user deliberately changes the profile variable and deploys a coordinator.

Common pitfalls

  • Changing max_prepared_transactions without applying its documented unit and configuration context.
  • Optimizing an isolated benchmark while ignoring concurrent aggregate resource use.
  • Assuming a configured value guarantees operating-system or storage behavior.
  • Failing to retest startup, failover, and workload latency after the change.

max_connections · max_locks_per_transaction · wal_level · max_wal_senders

References