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 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
ERROR: subquery uses ungrouped column "t.datetimea" from outer query LINE 3: ...*) FROM mytable w WHERE w.DATETIMEA::date BETWEEN t.DATETIME... ^
date | day | l7 | l30 |
---|---|---|---|
2020-03-16 | 1 | 1 | 1 |
2020-03-17 | 1 | 2 | 2 |
2020-03-18 | 1 | 3 | 3 |
2020-03-19 | 1 | 4 | 4 |
2020-03-20 | 1 | 5 | 5 |
2020-03-21 | 1 | 6 | 6 |
2020-03-22 | 2 | 8 | 8 |
2020-03-28 | 1 | 4 | 9 |
2020-03-29 | 1 | 4 | 10 |
2020-03-30 | 2 | 4 | 12 |
2020-03-31 | 1 | 5 | 13 |
SELECT 11