by munro · 11y ago · 0 comments
create index on invoice_docs((body->> 'created_at')::timestamptz)
Love hearing new Postgres features though :) -- jsonb for less space, new jsonb operators [1], & jsonb_path_ops for fast arbitrary querying [2].[1] http://www.postgresql.org/docs/9.4/static/functions-json.htm... [2] http://www.postgresql.org/docs/9.4/static/datatype-json.html...
The stuff I find really awesome is indexing for arbitrary expressions:
CREATE INDEX jsonb_index ON jsonb_table USING GIN (jsonb_column);
And then you can where whatever key/value you want, and it'll use the index.
Regarding size, it's more complicated. For example after loading the 'delicious-1250k' dataset from
http://randomwalker.info/data/delicious/
I get 1322MB for JSON and 1415MB for JSONB, so yes, in this case it's slightly larger.
FWIW, both JSON and JSONB use TOAST, because that's how PostgreSQL treats works around the 8kB page size (or whatever page size you use).