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 t
AS
SELECT
t.f[1] AS col1
,t.f[2]::int AS col2
,t.f[3]::date AS col3
,t.f[4] AS col4
FROM (
SELECT regexp_split_to_array(l, ',') AS f
FROM regexp_split_to_table(
$$a,1,2016-01-01,bbb
c,2,2018-01-01,ddd
e,3,2019-01-01,eee$$, '\n') AS l) t
SELECT 3
SELECT *
FROM t
col1 | col2 | col3 | col4 |
---|---|---|---|
a | 1 | 2016-01-01 | bbb |
c | 2 | 2018-01-01 | ddd |
e | 3 | 2019-01-01 | eee |
SELECT 3