aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/orindxpath.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-03-01 01:40:39 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-03-01 01:40:39 +0000
commitbfc294232192d32de22815ffced86fa17bc4d22f (patch)
tree244869ceaacc7a117d8058e1e0ba074b0e7470f1 /src/backend/optimizer/path/orindxpath.c
parent3da9fd85449d0fd353d81818671c82eac115e59a (diff)
downloadpostgresql-bfc294232192d32de22815ffced86fa17bc4d22f.tar.gz
postgresql-bfc294232192d32de22815ffced86fa17bc4d22f.zip
Adjust OR indexscan logic to not generate redundant condition-free OR
indexscans involving partial indexes. These would always be dominated by a simple indexscan on such an index, so there's no point in considering them. Fixes overoptimism in a patch I applied last October.
Diffstat (limited to 'src/backend/optimizer/path/orindxpath.c')
-rw-r--r--src/backend/optimizer/path/orindxpath.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/orindxpath.c b/src/backend/optimizer/path/orindxpath.c
index 210abfe1d9e..0afc8143fd8 100644
--- a/src/backend/optimizer/path/orindxpath.c
+++ b/src/backend/optimizer/path/orindxpath.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.64 2004/12/31 22:00:04 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.64.4.1 2005/03/01 01:40:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -387,10 +387,14 @@ best_or_subclause_index(Query *root,
/*
* Ignore index if it doesn't match the subclause at all; except
- * that if it's a partial index, consider it anyway, since the
- * selectivity of the predicate alone might make the index useful.
+ * that if it's a partial index matching the current OR subclause,
+ * consider it anyway, since effectively we are using the index
+ * predicate to match the subclause. (Note: we exclude partial
+ * indexes that are predOK; else such a partial index would be
+ * considered to match *every* OR subclause, generating bogus OR
+ * plans that are redundant with the basic scan on that index.)
*/
- if (indexclauses == NIL && index->indpred == NIL)
+ if (indexclauses == NIL && (index->indpred == NIL || index->predOK))
continue;
/* Convert clauses to indexquals the executor can handle */