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 7
INSERT 0 5
id | premium | |
---|---|---|
1 | some@email.com | t |
2 | another@email.com | f |
3 | third@email.com | t |
4 | fourth@email.com | t |
5 | fifth@email.com | t |
6 | sixth@email.com | f |
7 | seventh@email.com | t |
SELECT 7
id | referrer |
---|---|
2 | 1 |
3 | 1 |
4 | 1 |
5 | 2 |
6 | 2 |
SELECT 5
id | premium | referred | |
---|---|---|---|
1 | some@email.com | t | 3 |
2 | another@email.com | f | 2 |
4 | fourth@email.com | t | 0 |
5 | fifth@email.com | t | 0 |
7 | seventh@email.com | t | 0 |
3 | third@email.com | t | 0 |
6 | sixth@email.com | f | 0 |
SELECT 7