aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/selfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-05-28 16:04:02 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-05-28 16:04:02 +0000
commitfc8d970cbcdd6f025475822a4cf01dfda0873226 (patch)
treeca697026dbada6a022dec471191aab5a0ba7eb20 /src/backend/utils/adt/selfuncs.c
parente5f19598e07e9a0fc0a5c0f18bfac1fe92d21fc5 (diff)
downloadpostgresql-fc8d970cbcdd6f025475822a4cf01dfda0873226.tar.gz
postgresql-fc8d970cbcdd6f025475822a4cf01dfda0873226.zip
Replace functional-index facility with expressional indexes. Any column
of an index can now be a computed expression instead of a simple variable. Restrictions on expressions are the same as for predicates (only immutable functions, no sub-selects). This fixes problems recently introduced with inlining SQL functions, because the inlining transformation is applied to both expression trees so the planner can still match them up. Along the way, improve efficiency of handling index predicates (both predicates and index expressions are now cached by the relcache) and fix 7.3 oversight that didn't record dependencies of predicate expressions.
Diffstat (limited to 'src/backend/utils/adt/selfuncs.c')
-rw-r--r--src/backend/utils/adt/selfuncs.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 77ef33b8783..724503e9c4c 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.138 2003/05/26 00:11:27 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.139 2003/05/28 16:03:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3905,14 +3905,13 @@ btcostestimate(PG_FUNCTION_ARGS)
indexSelectivity, indexCorrelation);
/*
- * If it's a functional index, leave the default zero-correlation
- * estimate in place. If not, and if we can get an estimate for the
- * first variable's ordering correlation C from pg_statistic, estimate
+ * If the first column is a simple variable, and we can get an estimate
+ * for its ordering correlation C from pg_statistic, estimate
* the index correlation as C / number-of-columns. (The idea here is
* that multiple columns dilute the importance of the first column's
* ordering, but don't negate it entirely.)
*/
- if (index->indproc == InvalidOid)
+ if (index->indexkeys[0] != 0)
{
Oid relid;
HeapTuple tuple;
@@ -3942,8 +3941,7 @@ btcostestimate(PG_FUNCTION_ARGS)
Assert(nnumbers == 1);
varCorrelation = numbers[0];
- for (nKeys = 1; index->indexkeys[nKeys] != 0; nKeys++)
- /* skip */ ;
+ nKeys = index->ncolumns;
*indexCorrelation = varCorrelation / nKeys;