if (state->heapallindexed)
{
+ int64 total_pages;
int64 total_elems;
uint64 seed;
- /* Size Bloom filter based on estimated number of tuples in index */
- total_elems = (int64) state->rel->rd_rel->reltuples;
+ /*
+ * Size Bloom filter based on estimated number of tuples in index,
+ * while conservatively assuming that each block must contain at least
+ * MaxIndexTuplesPerPage / 5 non-pivot tuples. (Non-leaf pages cannot
+ * contain non-pivot tuples. That's okay because they generally make
+ * up no more than about 1% of all pages in the index.)
+ */
+ total_pages = RelationGetNumberOfBlocks(rel);
+ total_elems = Max(total_pages * (MaxIndexTuplesPerPage / 5),
+ (int64) state->rel->rd_rel->reltuples);
/* Random seed relies on backend srandom() call to avoid repetition */
seed = random();
/* Create Bloom filter to fingerprint index */
}
else
{
- int64 total_pages;
-
/*
* Extra readonly downlink check.
*
* splits and page deletions, though. This is taken care of in
* bt_downlink_missing_check().
*/
- total_pages = (int64) state->rel->rd_rel->relpages;
state->downlinkfilter = bloom_create(total_pages, work_mem, seed);
}
}