Cookbook recipe

Subtransactions and the multixact cost

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source
Estimated investigation4 min

Scenario

Heavy use of savepoints/PL functions with exception blocks can cause mysterious slowdowns from SLRU/multixact contention. Diagnose it Watch for SLRU-related waits: SELECT wait_event, count(*) FROM pg_stat_activity WHERE wait_event LIKE '%SLRU%' OR wait_event LIKE '%MultiXact%' GROUP BY…

Investigation Path

Heavy use of savepoints/PL functions with exception blocks can cause mysterious slowdowns from SLRU/multixact contention.

Diagnose it

Watch for SLRU-related waits:

SELECT wait_event, count(*) FROM pg_stat_activity
WHERE wait_event LIKE '%SLRU%' OR wait_event LIKE '%MultiXact%'
GROUP BY 1;

Why it happens

Each savepoint or PL/pgSQL EXCEPTION block opens a subtransaction with its own XID. Many concurrent row lockers create multixacts. Both rely on SLRU caches that can become contended at scale.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • How to fix it
  • Prevent it next time
  • Related & next steps
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes