From ba391ca500a514652fd24cc009eb92583e8263ea Mon Sep 17 00:00:00 2001 From: Julien Rouhaud Date: Tue, 17 Mar 2015 00:31:44 +0100 Subject: [PATCH] Fix index pages estimation --- pg_hypo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pg_hypo.c b/pg_hypo.c index 1a86d94..a6d7310 100644 --- a/pg_hypo.c +++ b/pg_hypo.c @@ -332,9 +332,10 @@ addHypotheticalIndex(PlannerInfo *root, if (index->indpred == NIL) { /* very quick and pessimistic estimation : - * number of tuples * avg width, with ~ 50% bloat, plus 1 block + * number of tuples * avg width, + * with ~ 50% bloat (including 10% fillfactor), plus 1 block */ - index->pages = (rel->tuples * ind_avg_width * .5 / BLCKSZ) + 1; + index->pages = (rel->tuples * ind_avg_width * 2 / BLCKSZ) + 1; /* partial index not supported yet, so assume all tuples are in the index */ index->tuples = rel->tuples; }