I have this table structure:
CREATE TABLE user_items
(
user_id bigint references users(id) NOT NULL,
item_id bigint references items(id) NOT NULL,
col1 json DEFAULT '[{"text":""}]',
col2 json DEFAULT '[{"date":"","text":""}]',
col3 json DEFAULT '{"text":""}',
PRIMARY KEY (user_id, item_id)
)
I will be running queries such as this:
SELECT * FROM user_items WHERE item_id = '?' AND col1 IS NOT NULL
Do I need an index (item_id, col1) in this case ?
And if so, what's the right way to do it, because when trying it Postgres is throwing an error since col1 is a JSON type.