Skip to content

Commit 9587170

Browse files
committed
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.
1 parent 295dd33 commit 9587170

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/backend/optimizer/path/orindxpath.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.64 2004/12/31 22:00:04 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/path/orindxpath.c,v 1.65 2005/03/01 01:40:05 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -387,10 +387,14 @@ best_or_subclause_index(Query *root,
387387

388388
/*
389389
* Ignore index if it doesn't match the subclause at all; except
390-
* that if it's a partial index, consider it anyway, since the
391-
* selectivity of the predicate alone might make the index useful.
390+
* that if it's a partial index matching the current OR subclause,
391+
* consider it anyway, since effectively we are using the index
392+
* predicate to match the subclause. (Note: we exclude partial
393+
* indexes that are predOK; else such a partial index would be
394+
* considered to match *every* OR subclause, generating bogus OR
395+
* plans that are redundant with the basic scan on that index.)
392396
*/
393-
if (indexclauses == NIL && index->indpred == NIL)
397+
if (indexclauses == NIL && (index->indpred == NIL || index->predOK))
394398
continue;
395399

396400
/* Convert clauses to indexquals the executor can handle */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy