By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
INSERT 0 6
CREATE INDEX
| id | name |
|---|---|
| 3 | Azamund |
| 4 | Azamund |
| 5 | azaMund |
SELECT 3
| id | thing | blueprint |
|---|---|---|
| 3 | thing 3 | {"1": {"name": "Azamund", "weight": "3"}, "2": {"name": "Iskapola", "weight": "1"}} |
| 4 | thing 4 | {"1": {"name": "Ulamir", "weight": "1"}, "2": {"name": "Azamund", "weight": "1"}} |
| 5 | thing 5 | {"3": {"name": "azaMund", "weight": "1"}} |
SELECT 3
| id | thing | blueprint |
|---|---|---|
| 3 | thing 3 | {"1": {"name": "Azamund", "weight": "3"}, "2": {"name": "Iskapola", "weight": "1"}} |
| 4 | thing 4 | {"1": {"name": "Ulamir", "weight": "1"}, "2": {"name": "Azamund", "weight": "1"}} |
SELECT 2
| id | thing | blueprint |
|---|---|---|
| 3 | thing 3 | {"1": {"name": "Azamund", "weight": "3"}, "2": {"name": "Iskapola", "weight": "1"}} |
| 4 | thing 4 | {"1": {"name": "Ulamir", "weight": "1"}, "2": {"name": "Azamund", "weight": "1"}} |
| 5 | thing 5 | {"3": {"name": "azaMund", "weight": "1"}} |
SELECT 3
| QUERY PLAN |
|---|
| Seq Scan on things t (cost=0.00..10.07 rows=3 width=68) |
| Filter: (SubPlan 1) |
| SubPlan 1 |
| -> Function Scan on jsonb_each b (cost=0.00..1.50 rows=1 width=0) |
| Filter: ((value ->> 'name'::text) ~~* 'azamund'::text) |
EXPLAIN
SET
| QUERY PLAN |
|---|
| Seq Scan on things t (cost=10000000000.00..10000000010.08 rows=3 width=68) |
| Filter: (SubPlan 1) |
| SubPlan 1 |
| -> Function Scan on jsonb_each b (cost=0.00..1.50 rows=1 width=0) |
| Filter: ((value ->> 'name'::text) ~~* 'azamund'::text) |
EXPLAIN
| QUERY PLAN |
|---|
| Bitmap Heap Scan on things t (cost=16.00..20.01 rows=1 width=68) |
| Recheck Cond: (blueprint @? '$.*?(@."name" == "Azamund")'::jsonpath) |
| -> Bitmap Index Scan on things_blueprint_gin_idx (cost=0.00..16.00 rows=1 width=0) |
| Index Cond: (blueprint @? '$.*?(@."name" == "Azamund")'::jsonpath) |
EXPLAIN
| QUERY PLAN |
|---|
| Bitmap Heap Scan on things t (cost=68.00..72.01 rows=1 width=68) |
| Recheck Cond: (blueprint @? '$.*?(@."name" like_regex "^azamund$" flag "i")'::jsonpath) |
| -> Bitmap Index Scan on things_blueprint_gin_idx (cost=0.00..68.00 rows=1 width=0) |
| Index Cond: (blueprint @? '$.*?(@."name" like_regex "^azamund$" flag "i")'::jsonpath) |
EXPLAIN
CREATE TABLE
INSERT 0 6
CREATE INDEX
| id | thing | blueprint |
|---|---|---|
| 3 | thing 3 | [{"name": "Azamund", "weight": "3"}, {"name": "Iskapola", "weight": "1"}] |
| 4 | thing 4 | [{"name": "Ulamir", "weight": "1"}, {"name": "Azamund", "weight": "1"}] |
| 5 | thing 5 | [{"name": "azaMund", "weight": "1"}] |
SELECT 3
| id | thing | blueprint |
|---|---|---|
| 3 | thing 3 | [{"name": "Azamund", "weight": "3"}, {"name": "Iskapola", "weight": "1"}] |
| 4 | thing 4 | [{"name": "Ulamir", "weight": "1"}, {"name": "Azamund", "weight": "1"}] |
SELECT 2
| id | thing | blueprint |
|---|---|---|
| 3 | thing 3 | [{"name": "Azamund", "weight": "3"}, {"name": "Iskapola", "weight": "1"}] |
| 4 | thing 4 | [{"name": "Ulamir", "weight": "1"}, {"name": "Azamund", "weight": "1"}] |
| 5 | thing 5 | [{"name": "azaMund", "weight": "1"}] |
SELECT 3
| QUERY PLAN |
|---|
| Bitmap Heap Scan on things_arr t (cost=8.00..12.01 rows=1 width=68) |
| Recheck Cond: (blueprint @? '$[*]?(@."name" == "Azamund")'::jsonpath) |
| -> Bitmap Index Scan on things_arr_foo_path_ops (cost=0.00..8.00 rows=1 width=0) |
| Index Cond: (blueprint @? '$[*]?(@."name" == "Azamund")'::jsonpath) |
EXPLAIN
| QUERY PLAN |
|---|
| Bitmap Heap Scan on things_arr t (cost=40.00..44.01 rows=1 width=68) |
| Recheck Cond: (blueprint @? '$[*]?(@."name" like_regex "^azamund$" flag "i")'::jsonpath) |
| -> Bitmap Index Scan on things_arr_foo_path_ops (cost=0.00..40.00 rows=1 width=0) |
| Index Cond: (blueprint @? '$[*]?(@."name" like_regex "^azamund$" flag "i")'::jsonpath) |
EXPLAIN