add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
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
CREATE TABLE
INSERT 0 10
INSERT 0 100
year product_id total_orders
2017-01-01 00:00:00+00 1 0
2017-01-01 00:00:00+00 2 0
2017-01-01 00:00:00+00 3 1
2017-01-01 00:00:00+00 4 0
2017-01-01 00:00:00+00 5 0
2017-01-01 00:00:00+00 6 0
2017-01-01 00:00:00+00 7 0
2017-01-01 00:00:00+00 8 0
2017-01-01 00:00:00+00 9 0
2017-01-01 00:00:00+00 10 0
2018-01-01 00:00:00+00 1 1
2018-01-01 00:00:00+00 2 0
2018-01-01 00:00:00+00 3 2
2018-01-01 00:00:00+00 4 0
2018-01-01 00:00:00+00 5 0
2018-01-01 00:00:00+00 6 1
2018-01-01 00:00:00+00 7 0
2018-01-01 00:00:00+00 8 1
2018-01-01 00:00:00+00 9 0
2018-01-01 00:00:00+00 10 0
2019-01-01 00:00:00+00 1 2
2019-01-01 00:00:00+00 2 0
2019-01-01 00:00:00+00 3 0
2019-01-01 00:00:00+00 4 1
2019-01-01 00:00:00+00 5 2
2019-01-01 00:00:00+00 6 1
2019-01-01 00:00:00+00 7 2
2019-01-01 00:00:00+00 8 0
2019-01-01 00:00:00+00 9 0
2019-01-01 00:00:00+00 10 0
2020-01-01 00:00:00+00 1 0
2020-01-01 00:00:00+00 2 2
2020-01-01 00:00:00+00 3 1
2020-01-01 00:00:00+00 4 1
2020-01-01 00:00:00+00 5 2
2020-01-01 00:00:00+00 6 3
2020-01-01 00:00:00+00 7 2
2020-01-01 00:00:00+00 8 1
2020-01-01 00:00:00+00 9 0
2020-01-01 00:00:00+00 10 0
2021-01-01 00:00:00+00 1 1
2021-01-01 00:00:00+00 2 1
2021-01-01 00:00:00+00 3 6
2021-01-01 00:00:00+00 4 2
2021-01-01 00:00:00+00 5 2
2021-01-01 00:00:00+00 6 2
2021-01-01 00:00:00+00 7 1
2021-01-01 00:00:00+00 8 1
2021-01-01 00:00:00+00 9 0
2021-01-01 00:00:00+00 10 0
2022-01-01 00:00:00+00 1 4
2022-01-01 00:00:00+00 2 1
2022-01-01 00:00:00+00 3 2
2022-01-01 00:00:00+00 4 0
2022-01-01 00:00:00+00 5 0
2022-01-01 00:00:00+00 6 2
2022-01-01 00:00:00+00 7 1
2022-01-01 00:00:00+00 8 2
2022-01-01 00:00:00+00 9 0
2022-01-01 00:00:00+00 10 0
2023-01-01 00:00:00+00 1 5
2023-01-01 00:00:00+00 2 8
2023-01-01 00:00:00+00 3 6
2023-01-01 00:00:00+00 4 2
2023-01-01 00:00:00+00 5 4
2023-01-01 00:00:00+00 6 7
2023-01-01 00:00:00+00 7 8
2023-01-01 00:00:00+00 8 6
2023-01-01 00:00:00+00 9 0
2023-01-01 00:00:00+00 10 0
SELECT 70