Using unbounded `text` in Postgres carries no performance penalty over `varchar(n)`, but it can create real-world problems when APIs fail to enforce length limits. A cautionary story from Stripe illustrates how the absence of string length constraints led to users sending massive payloads, making it nearly impossible to retroactively enforce limits without breaking integrations. The author now recommends using `varchar` with tiered, liberal limits (e.g., 200, 2000, 20000 characters) as a safety backstop, while also validating in application code. Postgres domains can encode these tiers as reusable types. Relaxing `varchar` constraints later is cheap in Postgres (no table rewrite needed when widening), making this approach operationally safe.

9m read timeFrom brandur.org
Post cover image
Table of contents
S3ripevarchars considered ~harm~helpfulIntegrity in depth
3 Impressions