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 12
client_id | start_date | end_date | continous_contract | contract_days | contract_nr | sum_days |
---|---|---|---|---|---|---|
1 | 2019-08-30 | 2020-02-29 | t | 183 | 0 | 183 |
1 | 2020-02-29 | 2020-08-29 | t | 182 | 0 | 365 |
1 | 2020-08-29 | 2021-02-28 | t | 183 | 0 | 548 |
2 | 2019-08-30 | 2020-02-29 | t | 183 | 0 | 183 |
2 | 2020-02-29 | 2020-08-29 | t | 182 | 0 | 365 |
2 | 2020-08-29 | 2021-02-28 | t | 183 | 0 | 548 |
3 | 2019-08-30 | 2020-02-29 | t | 183 | 0 | 183 |
3 | 2020-03-29 | 2020-09-29 | f | 184 | 1 | 184 |
3 | 2020-09-29 | 2021-03-28 | t | 180 | 1 | 364 |
3 | 2021-04-28 | 2021-10-28 | f | 183 | 2 | 183 |
3 | 2021-10-28 | 2022-04-28 | t | 182 | 2 | 365 |
3 | 2022-04-28 | 2022-10-28 | t | 183 | 2 | 548 |
SELECT 12