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 5
order_id | time_created | count_within_3_sec |
---|---|---|
1 | 2020-01-01 00:00:00 | 1 |
2 | 2020-01-01 00:00:01 | 2 |
3 | 2020-01-01 00:00:03 | 3 |
4 | 2020-01-01 00:00:05 | 2 |
5 | 2020-01-01 00:00:10 | 1 |
SELECT 5
order_id | time_created | count_within_3_sec |
---|---|---|
1 | 2020-01-01 00:00:00 | 1 |
2 | 2020-01-01 00:00:01 | 2 |
3 | 2020-01-01 00:00:03 | 3 |
4 | 2020-01-01 00:00:05 | 2 |
5 | 2020-01-01 00:00:10 | 1 |
SELECT 5
order_id | time_created | count_within_3_sec |
---|---|---|
1 | 2020-01-01 00:00:00 | 1 |
2 | 2020-01-01 00:00:01 | 2 |
3 | 2020-01-01 00:00:03 | 3 |
4 | 2020-01-01 00:00:05 | 2 |
5 | 2020-01-01 00:00:10 | 1 |
SELECT 5