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
INSERT 0 6
INSERT 0 3
INSERT 0 2
morderno | mgroup | mseq | mitem | mamt | munitprice |
---|---|---|---|---|---|
P1 | GA | 1 | A01 | 11 | 111 |
P1 | GA | 2 | A02 | 12 | 112 |
P1 | GB | 1 | B01 | 13 | 113 |
P1 | GB | 2 | B02 | 14 | 114 |
P1 | GC | 1 | C01 | 15 | 115 |
P1 | GC | 2 | C02 | 16 | 116 |
P2 | GA | 1 | A01 | 21 | 221 |
P2 | GB | 1 | B01 | 22 | 222 |
P2 | GC | 1 | C01 | 23 | 223 |
P3 | GB | 2 | B02 | 31 | 331 |
P3 | GC | 2 | C02 | 32 | 332 |
SELECT 11
DO
mgroup | p1_mitem | p1_mamt | p1_munitprice | p2_mitem | p2_mamt | p2_munitprice | p3_mitem | p3_mamt | p3_munitprice | p4_mitem | p4_mamt | p4_munitprice | p5_mitem | p5_mamt | p5_munitprice |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GA | A01 | 11 | 111 | A01 | 21 | 221 | null | null | null | null | null | null | null | null | null |
GA | A02 | 12 | 112 | null | null | null | null | null | null | null | null | null | null | null | null |
GB | B02 | 14 | 114 | null | null | null | B02 | 31 | 331 | null | null | null | null | null | null |
GB | B01 | 13 | 113 | B01 | 22 | 222 | null | null | null | null | null | null | null | null | null |
GC | C01 | 15 | 115 | C01 | 23 | 223 | null | null | null | null | null | null | null | null | null |
GC | C02 | 16 | 116 | null | null | null | C02 | 32 | 332 | null | null | null | null | null | null |
SELECT 6