Skip to content

Enforce limit of 64KB for JSONB column

Problem

Large JSONB columns can cause significant performance degradation at scale, leading to memory pressure, I/O amplification, and replication lag when individual records exceed reasonable size limits. Without enforcing limits, JSONB data can grow unbounded, impacting database performance across millions of records.

Solution

  • Implement 64KB hard limit constraint on JSONB columns to prevent performance issues
  • Add validation when the attribute is present.

Why 64KB?

A 64KB limit ensures JSONB data fits efficiently in memory pages and database buffers, preventing I/O amplification while still allowing substantial structured data storage. This threshold balances functionality with performance at GitLab's scale, where even modest per-record overhead becomes significant across millions of database entries.

Edited by Max Orefice