---
title: "What gets TOASTed in Postgres"
description: "Postgres TOAST kicks in once a row exceeds 2,032 bytes, compressing variable-length values largest-first and moving them into chunked pg_toast tables (1,996-byte chunks, 18-byte in-row pointers) when compression isn't enough."
url: "https://swe.quest/articles/what-gets-toasted-in-postgres-267438c13f618a84"
canonical: "https://planetscale.com/blog/what-gets-toasted-in-postgres"
source: "PlanetScale"
published: "2026-10-12"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 13
tags: ["postgres","storage-engines","performance"]
---

# What gets TOASTed in Postgres

A post on [PlanetScale](https://swe.quest/sources/planetscale.md), published 2026-10-12, 13 min read, Deep dive. Original: [https://planetscale.com/blog/what-gets-toasted-in-postgres](https://planetscale.com/blog/what-gets-toasted-in-postgres)

## Summary

Postgres TOAST kicks in once a row exceeds 2,032 bytes, compressing variable-length values largest-first and moving them into chunked pg\_toast tables (1,996-byte chunks, 18-byte in-row pointers) when compression isn't enough. Column storage strategies (PLAIN, EXTENDED, EXTERNAL, MAIN) control which of those happens, and TOAST differs from large objects in automation, the 1 GB limit, and deletion semantics. Comparing pglz (4 KB window, requires 25% savings) with LZ4 (64 KB window, single-candidate lookup, much faster) shows LZ4 catches more distant repeats and loads faster, while pglz compressed repetitive JSON smaller (19 vs 24 MB) and serves prefix reads like left(body, 200) far faster because Postgres can bound how many chunks it needs. EXTERNAL is the better choice for already-compressed data and for bytea values read from the middle (0.6 ms vs 43 ms LZ4 and 116 ms pglz).

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Storage engines](https://swe.quest/tags/storage-engines.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- data compression basics

## Keywords

TOAST, PostgreSQL, LZ4, pglz, pg\_column\_compression, large objects, PlanetScale

## Related posts

- [6 tips to optimize storage costs for your Postgres databases](https://swe.quest/articles/6-tips-to-optimize-storage-costs-for-your-postgres-databases-11da5e875c34786c.md): Neon · 2024-03-15 · Medium · 4 min read · PostgreSQL, Cost optimization, Storage engines
  Six ways to shrink Postgres storage spend: drop unused indexes (found via pg\_stat\_user\_indexes and pg\_index), avoid full database copies for dev and staging by using Neon's copy-on-write branching, choose smaller data types like SMALLINT, order columns largest to smallest to cut alignment padding, shorten Neon's history retention window, and tune autovacuum to limit bloat.
- [OLTP is expensive, you can ClickHouse it.](https://swe.quest/articles/oltp-is-expensive-you-can-clickhouse-it-cd5e8f20ed5b5b0f.md): ClickHouse · 2026-10-15 · Easy · 6 min read · PostgreSQL, Analytics & OLAP, Cost optimization, Storage engines, Event-driven architecture
  Data that has stopped changing doesn't need Postgres's ACID machinery, so it can be offloaded to ClickHouse for roughly an order of magnitude better unit economics.
- [Next steps for Postgres pluggable storage](https://swe.quest/articles/next-steps-for-postgres-pluggable-storage-b5bebbefbce05835.md): Supabase · 2023-05-01 · Easy · 3 min read · PostgreSQL, Storage engines, Open source
  Postgres 12 introduced a table access method (TAM) API intended to let different tables use different storage engines, but work on ZHeap and the API stalled, leaving gaps: index updates are all-or-nothing, and row versions must be identified by block and offset, which rules out index-organized tables and undo-based versioning.
- [Anatomy of a (Postgres) search engine](https://swe.quest/articles/anatomy-of-a-postgres-search-engine-ef0fff51702b4f16.md): PlanetScale · 2026-09-22 · Medium · 12 min read · Search, PostgreSQL, Data structures, Storage engines
  Inverted indexes power full-text search by mapping each term to a sorted, compressed postings list of document IDs, with optional positional data for phrase/span queries and frequency statistics for BM25 scoring.
- [Building a faster, lazier router for Postgres](https://swe.quest/articles/building-a-faster-lazier-router-for-postgres-bc9a70ce219128ed.md): PlanetScale · 2026-10-01 · Hard · 15 min read · PostgreSQL, Distributed databases, Performance engineering, Go, Query engines
  Neki, PlanetScale's Postgres sharding router, cuts per-query overhead by keeping PostgreSQL wire-protocol bytes intact and decoding only as much as each query requires.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
