The Index Nobody Uses
An engineer adds a GIN index on a jsonb column and the query that motivated it is unchanged:
CREATE INDEX events_payload_gin ON events USING GIN (payload);
EXPLAIN SELECT id FROM events WHERE payload ->> 'status' = 'failed';
-- Seq Scan on events (cost=0.00..2841002.00 rows=142000 width=8)
-- Filter: ((payload ->> 'status'::text) = 'failed'::text)
Why is the index never consulted?
Sign in to answer questions and track your progress
Sign In