By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
create table data_audit as select '{
"target": {
"ids": [
"ID1",
"ID2"
]
}
}'::json as body
SELECT 1
select * FROM data_audit cross join lateral
json_array_elements_text (body->'target'->'ids' ) as j(id)
where j.id ='ID1';
body | id |
---|---|
{ "target": { "ids": [ "ID1", "ID2" ] } } |
ID1 |
SELECT 1