By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
| id | items |
|---|---|
| 1 | [{"anz": 4, "typ": "Banana"}, {"anz": 5, "typ": "Apple"}, {"anz": 2, "typ": "Grapefruit"}] |
| 2 | [{"anz": 1, "typ": "Banana"}, {"anz": 1, "typ": "Apple"}, {"anz": 3, "typ": "Grapefruit"}] |
INSERT 0 2
| id | items |
|---|---|
| 1 | [{"anz": 4, "typ": "Banana"}, {"anz": 5, "typ": "Apple"}, {"anz": 2, "typ": "Grapefruit"}] |
| 2 | [{"anz": 1, "typ": "Banana"}, {"anz": 1, "typ": "Apple"}, {"anz": 3, "typ": "Grapefruit"}] |
SELECT 2
| id | items |
|---|
SELECT 0
| id | items |
|---|---|
| 1 | [{"anz": 4, "typ": "Banana"}, {"anz": 5, "typ": "Apple"}, {"anz": 2, "typ": "Grapefruit"}] |
SELECT 1
| id | jsonb_path_query |
|---|---|
| 1 | {"anz": 5, "typ": "Apple"} |
SELECT 1
| setseed |
|---|
SELECT 1
ERROR: could not write to file "base/pgsql_tmp/pgsql_tmp784.1": No space left on device
| QUERY PLAN |
|---|
| Seq Scan on public.fruits (cost=0.00..25.88 rows=13 width=36) (actual time=0.021..0.024 rows=1 loops=1) |
| Output: id, items |
| Filter: (fruits.items @? '$[*]?(@."typ" == "Apple" && @."anz" > 3)'::jsonpath) |
| Rows Removed by Filter: 1 |
| Planning Time: 0.050 ms |
| Execution Time: 0.044 ms |
EXPLAIN
CREATE INDEX
VACUUM
| QUERY PLAN |
|---|
| Seq Scan on public.fruits (cost=0.00..1.02 rows=1 width=158) (actual time=0.008..0.011 rows=1 loops=1) |
| Output: id, items |
| Filter: (fruits.items @? '$[*]?(@."typ" == "Apple" && @."anz" > 3)'::jsonpath) |
| Rows Removed by Filter: 1 |
| Planning Time: 0.114 ms |
| Execution Time: 0.018 ms |
EXPLAIN
| id | jsonb_pretty |
|---|
SELECT 0