By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
INSERT 0 3
| id | person |
|---|---|
| 2 | {"age": "73", "name": "Bob"} |
| 3 | {"age": "73", "name": "Bob"} |
SELECT 2
CREATE INDEX
SET
| QUERY PLAN |
|---|
| Nested Loop (cost=8.01..14.53 rows=1 width=36) |
| -> Bitmap Heap Scan on mytable t (cost=8.00..12.02 rows=1 width=36) |
| Recheck Cond: ((data -> 'people'::text) @> '[{"name": "Bob"}]'::jsonb) |
| -> Bitmap Index Scan on mytable_people_gin_idx (cost=0.00..8.00 rows=1 width=0) |
| Index Cond: ((data -> 'people'::text) @> '[{"name": "Bob"}]'::jsonb) |
| -> Function Scan on jsonb_array_elements p (cost=0.01..2.50 rows=1 width=32) |
| Filter: (((person ->> 'name'::text) = 'Bob'::text) AND (((person ->> 'age'::text))::integer > 30)) |
EXPLAIN