Is it expected that the planner in 8.1.3 (CVS) and HEAD doesn't use an index scan for the second query below when bitmap scans are disabled? Disabling sequential scans as well results in the planner using a bitmap scan.
test=> CREATE TABLE foo (id integer PRIMARY KEY); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo" CREATE TABLE test=> INSERT INTO foo SELECT * FROM generate_series(1, 100000); INSERT 0 100000 test=> ANALYZE foo; ANALYZE test=> SET enable_bitmapscan TO off; SET test=> EXPLAIN SELECT * FROM foo WHERE id IN (1); QUERY PLAN -------------------------------------------------------------------- Index Scan using foo_pkey on foo (cost=0.00..3.01 rows=1 width=4) Index Cond: (id = 1) (2 rows) test=> EXPLAIN SELECT * FROM foo WHERE id IN (1, 2); QUERY PLAN ------------------------------------------------------ Seq Scan on foo (cost=0.00..2041.00 rows=2 width=4) Filter: ((id = 1) OR (id = 2)) (2 rows) test=> SET enable_seqscan TO off; SET test=> EXPLAIN SELECT * FROM foo WHERE id IN (1, 2); QUERY PLAN ----------------------------------------------------------------------------- Bitmap Heap Scan on foo (cost=100000004.01..100000008.03 rows=2 width=4) Recheck Cond: ((id = 1) OR (id = 2)) -> BitmapOr (cost=4.01..4.01 rows=2 width=0) -> Bitmap Index Scan on foo_pkey (cost=0.00..2.00 rows=1 width=0) Index Cond: (id = 1) -> Bitmap Index Scan on foo_pkey (cost=0.00..2.00 rows=1 width=0) Index Cond: (id = 2) (7 rows) Here's the same query in 8.0.7: test=> EXPLAIN SELECT * FROM foo WHERE id IN (1, 2); QUERY PLAN ------------------------------------------------------------------------------ Index Scan using foo_pkey, foo_pkey on foo (cost=0.00..6.03 rows=2 width=4) Index Cond: ((id = 1) OR (id = 2)) (2 rows) -- Michael Fuhr ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match