On 30 Dec 2015, at 17:02, Tom Lane <tgl@sss.pgh.pa.us> wrote: Another idea would be to use the heap's row density as calculated by the last ANALYZE (ie, reltuples/relpages), with a fallback to 100 if relpages=0. This'd only be convenient if the bitmap scan node has the parent heap rel open, which it might not.
+1
Any objections to the attached?
Looks good to me. On my sample system with 100K rows, the new version gives me:
— CREATE TABLE test AS SELECT id FROM generate_series(1,100000) id;
— CREATE INDEX ON test USING brin(id);
postgres=# explain analyze select 1 from test where id = 500;