Postgres Array column vs JSONB column

Viewed 1136
1 Answers

Syntactically, the JSONB array may be easier to use as you don't have to wrap your query value in a dummy array constructor:

where jsonbcolumn ? 'abc';

vs

where textarraycolumn @> ARRAY['abc']

On the other hand, the planner is likely to make better decisions with the PostgreSQL array, as it collects statistics on its contents, but doesn't on JSONB.

Also, you should read the docs for the version of PostgreSQL you are using, which is hopefully greater than 9.4 and really really should be greater than 9.1.

Related