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
age | name | scores |
---|---|---|
25 | Name1 | {10,20,30} |
48 | Name2 | {40,50,60,70} |
INSERT 0 2
scores | scores | scores |
---|---|---|
40 | 50 | 60 |
SELECT 1
age | name | scores | score | score_number |
---|---|---|---|---|
25 | Name1 | {10,20,30} | 10 | 1 |
25 | Name1 | {10,20,30} | 20 | 2 |
25 | Name1 | {10,20,30} | 30 | 3 |
48 | Name2 | {40,50,60,70} | 40 | 1 |
48 | Name2 | {40,50,60,70} | 50 | 2 |
48 | Name2 | {40,50,60,70} | 60 | 3 |
48 | Name2 | {40,50,60,70} | 70 | 4 |
SELECT 7
CREATE FUNCTION
f_employee_scores_into_columns |
---|
output_f_employee_scores_into_columns |
SELECT 1
age | name | score_1 | score_2 | score_3 | score_4 |
---|---|---|---|---|---|
48 | Name2 | 40 | 50 | 60 | 70 |
SELECT 1
f_employee_scores_into_columns |
---|
output_f_employee_scores_into_columns |
SELECT 1
age | name | score_1 | score_2 | score_3 |
---|---|---|---|---|
25 | Name1 | 10 | 20 | 30 |
SELECT 1