JSONB and binary JSON storage
JSONB means parse once on write, query fast on read. PostgreSQL coined the name, MySQL's JSON already works that way, SQLite added a JSONB blob format in 3.45, and SQL Server got a binary json type in 2025.
- Family
- JSON & semi-structured
- Missing in
- None of the five
- Gotchas
- 5 listed
Engine by engine
Binary JSON trades write cost and exact text for faster reads and indexability. PostgreSQL JSONB is the reference; MySQL JSON and Oracle's OSON JSON are the same idea under other names.
| 引擎 | 類型 | 儲存 | 備註 |
|---|---|---|---|
| SQL Server |
json (2025) or NVARCHAR(MAX)
|
Variable | SQL Server 2025 adds a native json type (binary, like JSONB). On 2022 and earlier, NVARCHAR(MAX) plus functions is the only option. |
| PostgreSQL |
JSONB
|
Binary, variable | Decomposed tree on disk, duplicate keys collapsed (last wins), insignificant whitespace dropped; GIN-indexable for @> containment. The default choice for JSON columns. |
| MySQL |
JSON (already binary)
|
Binary, variable | MySQL's JSON type stores parsed binary from day one, so it plays jsonb's role; there is no separate jsonb name. |
| SQLite |
BLOB (JSONB format)
|
BLOB limits | 3.45 added JSONB: jsonb() converts text to a binary BLOB that the json_* functions read without re-parsing. There is no JSONB column type; the BLOB is just a value. |
| Oracle |
JSON type (OSON)
|
Binary, variable | Native JSON since 21c stores as OSON, an Oracle binary JSON encoding; 23ai adds JSON Schema validation and JSON-relational duality views. |
Gotchas
Where the engines disagree. These tend to surface as bugs during a migration or a port.
- PostgreSQL JSONB does not preserve key order, whitespace or duplicate keys: round-tripping a document through jsonb silently rewrites it. If a diff or signature depends on the text, store the text too.
- SQLite's JSONB is not a column type: it is a BLOB value that only SQLite understands. Storing it on disk is allowed, but the docs tell applications not to read or build the format outside SQLite.
- SQL Server 2025's json type is new enough that most code targets NVARCHAR(MAX); ORMs and drivers that assume the old model need the type mapping checked before you adopt it.
- MySQL sorts out duplicate keys at write time too: since 8.0.3 the last duplicate wins, as in jsonb, while 5.7 kept the first. Data migrated from 5.7 can read differently.
- GIN indexes on PostgreSQL JSONB make writes slower and bigger; indexing every key by default is a common way to turn a fast column into the table's write bottleneck.
Common questions
Is jsonb always better than json in PostgreSQL?
For querying, yes. json wins only if you must return byte-identical documents (key order, duplicate keys) or log the exact payload received. Both validate on write.
Does MySQL have a jsonb type?
No, and it does not need one: MySQL's JSON type has stored parsed binary JSON since 5.7, which is what jsonb does. The names differ, the behavior matches.
What is SQLite's JSONB then?
A binary format introduced in 3.45: jsonb(text) produces it, the json_* and jsonb_* functions consume it without re-parsing, and it can be stored in a BLOB column. Applications are told not to read or write the format themselves.
Related on SQLly
Map a type to the other four engines
The free type converter maps a type from one engine to its closest equivalent in the others and says where storage, precision or behaviour differ. The desktop app does the same mapping while you edit.