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?.
9 rows affected
id | sensor_id | timestamp | value |
---|---|---|---|
1 | 1 | 2020-08-16 12:00:00 | 5 |
2 | 2 | 2020-08-16 12:01:00 | 6 |
3 | 1 | 2020-08-16 12:02:00 | 4 |
4 | 2 | 2020-08-16 12:02:00 | 7 |
5 | 2 | 2020-08-16 12:03:00 | 3 |
6 | 1 | 2020-08-16 12:05:00 | 3 |
7 | 2 | 2020-08-16 12:06:00 | 4 |
8 | 2 | 2020-08-16 12:07:00 | 5 |
9 | 1 | 2020-08-16 12:08:00 | 6 |
timestamp | value_1 | value_2 | diff |
---|---|---|---|
2020-08-16 12:00:00 | 5 | null | null |
2020-08-16 12:01:00 | 5 | 6 | 1 |
2020-08-16 12:02:00 | 4 | 7 | 3 |
2020-08-16 12:03:00 | 4 | 3 | 1 |
2020-08-16 12:05:00 | 3 | 3 | 0 |
2020-08-16 12:06:00 | 3 | 4 | 1 |
2020-08-16 12:07:00 | 3 | 5 | 2 |
2020-08-16 12:08:00 | 6 | 5 | 1 |
timestamp | value_1 | value_2 | diff | prev_diff | next_diff |
---|---|---|---|---|---|
2020-08-16 12:01:00 | 5 | 6 | 1 | null | 3 |
2020-08-16 12:05:00 | 3 | 3 | 0 | 1 | 1 |
2020-08-16 12:08:00 | 6 | 5 | 1 | 2 | null |
timestamp | value_1 | value_2 | diff | test_for_dup | prev_diff | next_diff |
---|---|---|---|---|---|---|
2020-08-16 12:01:00 | 5 | 6 | 1 | null | null | 3 |
2020-08-16 12:05:00 | 3 | 3 | 0 | 1 | 1 | 1 |
2020-08-16 12:08:00 | 6 | 5 | 1 | 2 | 2 | null |