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 FUNCTION
f_has_missing | f_has_missing | f_has_missing | f_has_missing | f_has_missing | f_has_missing |
---|---|---|---|---|---|
f | t | t | t | t | t |
SELECT 1
SET
QUERY PLAN |
---|
Result (cost=24.62..24.63 rows=1 width=1) |
InitPlan 1 (returns $0) |
-> Bitmap Heap Scan on gaps (cost=10.00..24.62 rows=1 width=0) |
Filter: ((all_full <> ''::text) IS NOT TRUE) |
-> Bitmap Index Scan on gaps_pkey (cost=0.00..10.00 rows=370 width=0) |
EXPLAIN
QUERY PLAN |
---|
Result (cost=17.31..17.32 rows=1 width=1) |
InitPlan 1 (returns $0) |
-> Bitmap Heap Scan on gaps (cost=10.00..24.62 rows=2 width=0) |
Filter: (COALESCE(all_full, ''::text) = ''::text) |
-> Bitmap Index Scan on gaps_pkey (cost=0.00..10.00 rows=370 width=0) |
EXPLAIN
QUERY PLAN |
---|
Result (cost=10.69..10.70 rows=1 width=1) |
InitPlan 1 (returns $0) |
-> Bitmap Heap Scan on gaps (cost=8.32..15.43 rows=3 width=0) |
Recheck Cond: ((all_full = ''::text) OR (all_full IS NULL)) |
-> BitmapOr (cost=8.32..8.32 rows=3 width=0) |
-> Bitmap Index Scan on gaps_pkey (cost=0.00..4.16 rows=1 width=0) |
Index Cond: (all_full = ''::text) |
-> Bitmap Index Scan on gaps_pkey (cost=0.00..4.16 rows=2 width=0) |
Index Cond: (all_full IS NULL) |
EXPLAIN