2 ms·
You don't even need these additional columns in PostgreSQL, thanks to expression indexes! [1] Just add an expression index for your new field: CREATE INDE
by vog 10y ago
You don't even need these additional columns in PostgreSQL, thanks to expression indexes! [1]
Just add an expression index for your new field:
CREATE INDEX ON blah BTREE ((jsoncolumn->>'new_thing'));
Then, the following kind of queries are blazingly fast due to the index:
SELECT * FROM blah WHERE jsoncolumn->>'new_thing' = 'some_value';
This is less error prone than managing the consistency of the additional columns on your own. And if you still need some kind of pseudo-table, consider creating a simple view for that.
[1] https://www.postgresql.org/docs/current/static/indexes-expressional.html https://www.postgresql.org/docs/current/static/indexes-expre...