By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
SELECT 5
| myfield |
|---|
| {"a": "0", "b": "0"} |
| {"c": "1", "d": "0"} |
| {"e": null, "f": true} |
| {"g": 0, "h": 0.0} |
| {"i": "0", "j": false} |
SELECT 5
| myfield |
|---|
| {"a": "0", "b": "0"} |
SELECT 1
| myfield |
|---|
| {"a": "0", "b": "0"} |
SELECT 1
| myfield |
|---|
| {"a": "0", "b": "0"} |
SELECT 1
| myfield |
|---|
| {"a": "0", "b": "0"} |
SELECT 1
| setseed |
|---|
SELECT 1
INSERT 0 100000
| jsonb_pretty |
|---|
| { "e": true, "l": null, "m": "2024-02-02" } |
| { "b": "abc", "i": "0" } |
| { "i": "abc", "j": "0", "q": "2024-02-02" } |
| { "g": null, "i": 0, "k": null } |
| { "g": 0, "n": "abc", "o": "0" } |
SELECT 5
CREATE INDEX
VACUUM
| QUERY PLAN |
|---|
| Bitmap Heap Scan on public.mytabel (cost=768.08..805.05 rows=10 width=42) (actual time=18.512..125.622 rows=192 loops=1) |
| Output: myfield |
| Recheck Cond: (mytabel.myfield @@ '!(exists ($.*?(@ != "0" || @.type() != "string")))'::jsonpath) |
| Rows Removed by Index Recheck: 99813 |
| Heap Blocks: exact=907 |
| -> Bitmap Index Scan on mytabel_myfield_idx (cost=0.00..768.07 rows=10 width=0) (actual time=18.386..18.386 rows=100005 loops=1) |
| Index Cond: (mytabel.myfield @@ '!(exists ($.*?(@ != "0" || @.type() != "string")))'::jsonpath) |
| Planning Time: 0.320 ms |
| Execution Time: 125.705 ms |
EXPLAIN