aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/selfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-03-30 00:53:30 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-03-30 00:53:30 +0000
commite55985d3be4aed47c703674c735c124ff0b3c03c (patch)
tree4be5accd90a1c1561737d9297ab0df7eec74118c /src/backend/utils/adt/selfuncs.c
parent341dc91820b3f80ae69a51f2780fd0d8afcb2c47 (diff)
downloadpostgresql-e55985d3be4aed47c703674c735c124ff0b3c03c.tar.gz
postgresql-e55985d3be4aed47c703674c735c124ff0b3c03c.zip
Tweak indexscan cost estimation: round estimated # of tuples visited up
to next integer. Previously, if selectivity was small, we could compute very tiny scan cost on the basis of estimating that only 0.001 tuple would be fetched, which is silly. This naturally led to some rather silly plans...
Diffstat (limited to 'src/backend/utils/adt/selfuncs.c')
-rw-r--r--src/backend/utils/adt/selfuncs.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index af7a449f697..0cd408ed78f 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -15,13 +15,15 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.61 2000/03/23 00:55:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.62 2000/03/30 00:53:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
+#include <math.h>
+
#include "access/heapam.h"
#include "catalog/catname.h"
#include "catalog/pg_operator.h"
@@ -900,10 +902,10 @@ genericcostestimate(Query *root, RelOptInfo *rel,
lfirsti(rel->relids));
/* Estimate the number of index tuples that will be visited */
- numIndexTuples = *indexSelectivity * index->tuples;
+ numIndexTuples = ceil(*indexSelectivity * index->tuples);
/* Estimate the number of index pages that will be retrieved */
- numIndexPages = *indexSelectivity * index->pages;
+ numIndexPages = ceil(*indexSelectivity * index->pages);
/*
* Compute the index access cost.