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 iris(sepal_length real, sepal_width real);
create table raw_json(data jsonb);
CREATE TABLE
CREATE TABLE
insert into raw_json (data) values
(
'[{"sepal_width":3.5,"sepal_length":5.1},{"sepal_width":3.0,"sepal_length":4.9}]
')
INSERT 0 1
INSERT INTO iris(sepal_length,sepal_width)
select (j->>'sepal_length' ) ::real,
(j->>'sepal_width' ) ::real
from raw_json cross join jsonb_array_elements(data) as j;
INSERT 0 2
select * from iris;
sepal_length | sepal_width |
---|---|
5.1 | 3.5 |
4.9 | 3 |
SELECT 2