diff options
| author | Tom Lane | 2006-07-01 22:07:23 +0000 |
|---|---|---|
| committer | Tom Lane | 2006-07-01 22:07:23 +0000 |
| commit | 08ccdf020e65d8670936317909e5c48c818eab85 (patch) | |
| tree | fcd2257618e09117711cba14d4d20a8f0d4e5eb4 /src/backend/optimizer | |
| parent | cffd89ca736e485309cd51ae056f837bd7e683ad (diff) | |
Fix oversight in planning for multiple indexscans driven by
ScalarArrayOpExpr index quals: we were estimating the right total
number of rows returned, but treating the index-access part of the
cost as if a single scan were fetching that many consecutive index
tuples. Actually we should treat it as a multiple indexscan, and
if there are enough of 'em the Mackert-Lohman discount should kick in.
Diffstat (limited to 'src/backend/optimizer')
| -rw-r--r-- | src/backend/optimizer/path/costsize.c | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index eec165ab5db..2ef3e3759a1 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -54,7 +54,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.159 2006/07/01 18:38:32 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.160 2006/07/01 22:07:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -112,7 +112,6 @@ bool enable_hashjoin = true; static bool cost_qual_eval_walker(Node *node, QualCost *total); -static int estimate_array_length(Node *arrayexpr); static Selectivity approx_selectivity(PlannerInfo *root, List *quals, JoinType jointype); static Selectivity join_in_selectivity(JoinPath *path, PlannerInfo *root); @@ -692,34 +691,6 @@ cost_tidscan(Path *path, PlannerInfo *root, } /* - * Estimate number of elements in the array yielded by an expression. - */ -static int -estimate_array_length(Node *arrayexpr) -{ - if (arrayexpr && IsA(arrayexpr, Const)) - { - Datum arraydatum = ((Const *) arrayexpr)->constvalue; - bool arrayisnull = ((Const *) arrayexpr)->constisnull; - ArrayType *arrayval; - - if (arrayisnull) - return 0; - arrayval = DatumGetArrayTypeP(arraydatum); - return ArrayGetNItems(ARR_NDIM(arrayval), ARR_DIMS(arrayval)); - } - else if (arrayexpr && IsA(arrayexpr, ArrayExpr)) - { - return list_length(((ArrayExpr *) arrayexpr)->elements); - } - else - { - /* default guess */ - return 10; - } -} - -/* * cost_subqueryscan * Determines and returns the cost of scanning a subquery RTE. */ |
