Before that ◦ hstore ▪ Basic key/value store ▪ No nesting support ◦ JSON ▪ Simple text storage ▪ No good performance • JSONB ◦ Nesting support ◦ Saves as binary format ▪ Internally typed ◦ Great performance and querying support ◦ Supports index (full and specific)
( select jsonb_array_elements(items)::jsonb as items from orders where items @> '[{ "department": "Games" }]' ) as items where items @> '{"department": "Games"}' group by items->>'name' order by total desc limit 10 -- 9.2s