0

Data types & their traps

Schemaused in ~95% of apps

The column type you pick is not a formality — it is the difference between a bug that is impossible and a bug that is common. Store money as a float and a customer's total is eventually off by a cent in a way no one can reproduce. Store "when this happened" without a timezone and the same instant reads differently depending on which server's clock displayed it. None of these throw an error. They just quietly lie, forever, in production.

Core idea. Postgres gives you more precise types than the ones a beginner reaches for by habit, and almost every type trap has the same shape: the familiar-looking choice compiles, runs, and looks correct in a demo — right up until it silently loses precision (float for money), silently loses meaning (timestamp with no zone), or silently returns the wrong thing to compare against (jsonb's -> versus ->>). Pick the precise type on day one; there is no migration that un-loses data that was never stored correctly.
Playground, this isn't a screenshot
Live demointeractive
Real Postgres · in your browseridle
Run it as written. 0.1 + 0.2 is not 0.3 in one of these columns — which one, and why does it matter for money?
Cmd/Ctrl + Enter
↑ play a little first, then dig in