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 7
CREATE TABLE
INSERT 0 2
id | name | salary | departmentid | rn |
---|---|---|---|---|
4 | Den | 90000 | 1 | 1 |
1 | Petr | 85000 | 1 | 2 |
6 | Kir | 85000 | 1 | 2 |
7 | Mike | 76000 | 1 | 3 |
5 | Bob | 69000 | 1 | 4 |
2 | Ivan | 80000 | 2 | 1 |
3 | Alex | 60000 | 2 | 2 |
SELECT 7
departement | employee | salary |
---|---|---|
IT | Den | 90000 |
IT | Petr | 85000 |
IT | Kir | 85000 |
IT | Mike | 76000 |
Sales | Ivan | 80000 |
Sales | Alex | 60000 |
SELECT 6