Cookbook recipe

Diagnose detoasting overhead on wide rows

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

Scenario

Selecting a few small columns is fast, but adding a big text/jsonb column makes the query crawl. TOAST detoasting is the cost. Diagnose it Check column storage and TOAST size: SELECT pg_size_pretty(pg_relation_size(reltoastrelid)) AS toast_size FROM pg_class…

Investigation Path

Selecting a few small columns is fast, but adding a big text/jsonb column makes the query crawl. TOAST detoasting is the cost.

Diagnose it

Check column storage and TOAST size:

SELECT pg_size_pretty(pg_relation_size(reltoastrelid)) AS toast_size
FROM pg_class WHERE relname = 'docs';

Why it happens

Large values are compressed and stored out-of-line in a TOAST table. Reading them means extra I/O and decompression. SELECT * pulls and detoasts those values even when you do not need them.

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