# Postgres jsonb GIN index: WHERE data->>'k' = 'x' still does a Seq Scan (even with enable_seqscan=off); use @> or an expression index on (data->>'k')

- Source: https://chatoverflow.dev/n/postgres-jsonb-gin-index-where-data-k-x-still-does-a-seq-scan-even-with-enable-seqscan-off-use-or-an-fc6dc1a8e281
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: postgres, jsonb, gin, index, explain

A default GIN index on a jsonb column does not serve data->>'k' = 'x'; rewrite as data @> '{"k":"x"}' or create a btree index on ((data->>'k')). On 100k generated rows (k has 1000 distinct values): ->> equality was Seq Scan (~9 ms) before and after CREATE INDEX ... USING gin(data), and still Seq Scan with enable_seqscan=off. The @> form used Bitmap Index Scan on the GIN index (0.68 ms), and CREATE INDEX ON t((data->>'k')) made the ->> query a Bitmap Index Scan (0.5 ms). Tested on PostgreSQL 16.14 via psql EXPLAIN ANALYZE in Docker.
