add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
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?.
version
PostgreSQL 16.0 (Debian 16.0-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
SELECT 1
CREATE TABLE
CREATE INDEX
CREATE INDEX
CREATE INDEX
INSERT 0 10000
INSERT 0 3
ANALYZE
QUERY PLAN
Bitmap Heap Scan on pairs (cost=12.40..22.34 rows=3 width=4) (actual time=0.019..0.020 rows=3 loops=1)
  Recheck Cond: ((key = 'foo'::text) OR (key = 'bar'::text) OR (key = 'baz'::text))
  Filter: (value > 10)
  Heap Blocks: exact=1
  -> BitmapOr (cost=12.40..12.40 rows=3 width=0) (actual time=0.011..0.011 rows=0 loops=1)
        -> Bitmap Index Scan on pairs_key_idx (cost=0.00..4.13 rows=1 width=0) (actual time=0.004..0.005 rows=1 loops=1)
              Index Cond: (key = 'foo'::text)
        -> Bitmap Index Scan on pairs_key_idx1 (cost=0.00..4.13 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=1)
              Index Cond: (key = 'bar'::text)
        -> Bitmap Index Scan on pairs_key_idx2 (cost=0.00..4.13 rows=1 width=0) (actual time=0.001..0.001 rows=1 loops=1)
              Index Cond: (key = 'baz'::text)
Planning Time: 0.370 ms
Execution Time: 0.052 ms
EXPLAIN
QUERY PLAN
Seq Scan on pairs (cost=0.00..216.55 rows=3 width=4) (actual time=1.626..1.627 rows=3 loops=1)
  Filter: ((value > 10) AND (key = ANY ('{foo,bar,baz}'::text[])))
  Rows Removed by Filter: 10000
Planning Time: 0.062 ms
Execution Time: 1.635 ms
EXPLAIN
QUERY PLAN
Seq Scan on pairs (cost=0.00..216.55 rows=3 width=4) (actual time=1.606..1.606 rows=3 loops=1)
  Filter: ((value > 10) AND (key = ANY ('{foo,bar,baz}'::text[])))
  Rows Removed by Filter: 10000
Planning Time: 0.052 ms
Execution Time: 1.613 ms
EXPLAIN
value
25
50
75
SELECT 3
value
25
50
75
SELECT 3
value
25
50
75
SELECT 3