Benchmarks

Operation speed and serialised size versus SQLite’s JSON and JSONB.

Performance benchmarks

Nanoseconds per operation — lower is better.

json/mp and jsonb/mp: ratio relative to msgpack (>1 means msgpack is faster).

Platform: macOS · SQLite 3.53.1

Operation msgpack ns/op json ns/op jsonb ns/op json/mp jsonb/mp
map build (4 fields)408.31168.31408.82.86x3.45x
array build (8 integers)328.9584.9757.71.78x2.30x
nested build (map + array)782.8647.61218.10.83x1.56x
extract text field ($.name)573.9944.6649.31.65x1.13x
extract numeric field ($.score)577.21016.6767.31.76x1.33x
type check ($.name)549.6914.2n/a1.66xn/a
set field ($.extra = 42)818.71590.7950.11.94x1.16x
remove field ($.active)865.61218.0719.81.41x0.83x
group_array (1 000 rows)88231.7127026.7142550.01.44x1.62x
group_object (1 000 rows)130031.7184090.0215260.01.42x1.66x
each — iterate 4-field map2986.11172.61004.00.39x0.34x
valid check536.4812.3n/a1.51xn/a
from_json (parse JSON text → blob)1000.6n/an/an/an/a
to_json (serialise blob → JSON text)1588.2n/an/an/an/a
sqlite-msgpack vs JSON vs JSONB performance
sqlite-msgpack vs JSON vs JSONB performance

Serialised-size comparison

Byte sizes for identical logical data encoded as msgpack, JSON (text), and SQLite JSONB (binary). mp/json % and mp/jsonb % show msgpack size as a percentage of the other format — below 100 % means msgpack is more compact.

Platform: macOS · SQLite 3.53.1

Payload msgpack (B) json (B) jsonb (B) mp/json % mp/jsonb %
null14125%100%
true (via from_json)14125%100%
false (via from_json)15120%100%
integer 0112100%50%
integer 4212350%33%
integer 128 (uint8 boundary)23467%50%
integer 65536 (uint32 range)556100%83%
integer 1 000 000 0005101150%45%
integer -112350%33%
integer -128 (int8 boundary)24550%40%
float 3.14945225%180%
string 2 chars ("hi")34375%100%
string 11 chars ("hello world")12131292%100%
string 31 chars (fixstr max)32333397%97%
string 32 chars (str8 range)343434100%100%
array 3 ints [1,2,3]47757%57%
array 10 ints [1..10]11222350%48%
array 10 floats [1.1..10.1]914243217%212%
map 2 fields {a:1,b:2}713954%78%
user record (5 fields)49634678%107%
full user record (8 fields)10213010478%98%
nested 3 levels {a:{b:{c:42}}}10201250%83%
array of 3 user objects62987563%83%
config object (mixed types)871168875%99%
array 100 integers [1..100]10329329535%35%
Serialised-size comparison
Serialised-size comparison