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 3
CREATE TABLE
INSERT 0 3
CREATE FUNCTION
ct1 | ct2 | ct3 |
---|---|---|
1 | 0 | 2 |
SELECT 1
id | descr | ct |
---|---|---|
1 | size should not greater than width | 1 |
2 | size should not greater than height | 0 |
3 | with should be equal to height | 2 |
SELECT 3
?column? |
---|
SELECT x.* FROM (SELECT count(*) FILTER (WHERE size > width) AS c1, count(*) FILTER (WHERE size > height) AS c2, count(*) FILTER (WHERE width <> height) AS c3 FROM testtable) t, LATERAL (VALUES (1, 'size should not greater than width', c1), (2, 'size should not greater than height', c2), (3, 'with should be equal to height', c3)) x(id, dscr, ct) |
SELECT 1
id | descr | ct |
---|---|---|
1 | size should not greater than width | 1 |
2 | size should not greater than height | 0 |
3 | with should be equal to height | 2 |
SELECT 3