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 4
id | date | week_number | count_til_last_week |
---|---|---|---|
1 | 2023-10-07 | 40 | 0 |
2 | 2023-10-08 | 41 | 1 |
3 | 2023-10-14 | 41 | 1 |
4 | 2023-10-22 | 43 | 3 |
SELECT 4
year | week_number | count_til_last_week |
---|---|---|
2023 | 40 | null |
2023 | 41 | 1 |
2023 | 43 | 3 |
SELECT 3