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 12
CREATE INDEX
col_a | col_b |
---|---|
A | 35 |
B | 21 |
C | 41 |
SELECT 3
SET
QUERY PLAN |
---|
CTE Scan on cte (cost=11.22..11.44 rows=11 width=36) |
CTE cte |
-> Recursive Union (cost=1.15..11.22 rows=11 width=36) |
-> Limit (cost=1.15..2.17 rows=1 width=36) |
-> Index Only Scan using tbl_col_a_col_b_idx on tbl (cost=0.14..12.31 rows=12 width=36) |
-> Limit (cost=0.51..0.88 rows=1 width=36) |
-> Nested Loop (cost=0.14..15.11 rows=40 width=36) |
Join Filter: (t.col_a > c.col_a) |
-> Index Only Scan using tbl_col_a_col_b_idx on tbl t (cost=0.14..12.31 rows=12 width=36) |
-> WorkTable Scan on cte c (cost=0.00..0.20 rows=10 width=32) |
EXPLAIN