提交 95871703 编写于 作者: T Tom Lane

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.
上级 295dd338
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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.65 2005/03/01 01:40:05 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -387,10 +387,14 @@ best_or_subclause_index(Query *root, ...@@ -387,10 +387,14 @@ best_or_subclause_index(Query *root,
/* /*
* Ignore index if it doesn't match the subclause at all; except * Ignore index if it doesn't match the subclause at all; except
* that if it's a partial index, consider it anyway, since the * that if it's a partial index matching the current OR subclause,
* selectivity of the predicate alone might make the index useful. * 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; continue;
/* Convert clauses to indexquals the executor can handle */ /* Convert clauses to indexquals the executor can handle */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册