Two of my PostgreSQL DB columns are JSONB fields (J1, J2). My queries are on (J1->>'f1')::int
and (J2->>'f2')
, for example:
SELECT * from table where (J1->>'f1')::int = 1 AND (J2->>'f2') IS NULL;
Since I have millions of records, I created a composite index:
CREATE INDEX f1_f2 ON table (((J1->>'f1')::int), (J2->>'f2'));
However, looking at EXPLAIN
, I see that Seq Scan
on table is still being used. Is this because PG does not handle composite JSONB fields? Any other reason that I should check?