Skip to content

Commit bf0b6ac

Browse files
committed
Skip opfamily check in eclass_matches_any_index() when the index isn't a
btree. We can't easily tell whether clauses generated from the equivalence class could be used with such an index, so just assume that they might be. This bit of over-optimization prevented use of non-btree indexes for nestloop inner indexscans, in any case where the join uses an equality operator that is also a btree operator --- which in particular is typically true for hash indexes. Noted while trying to test the current hash index patch.
1 parent cdd0895 commit bf0b6ac

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/backend/optimizer/path/indxpath.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.232 2008/08/14 18:47:59 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.233 2008/09/12 14:56:13 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -1584,7 +1584,18 @@ eclass_matches_any_index(EquivalenceClass *ec, EquivalenceMember *em,
15841584
{
15851585
Oid curFamily = families[0];
15861586

1587-
if (list_member_oid(ec->ec_opfamilies, curFamily) &&
1587+
/*
1588+
* If it's a btree index, we can reject it if its opfamily isn't
1589+
* compatible with the EC, since no clause generated from the
1590+
* EC could be used with the index. For non-btree indexes,
1591+
* we can't easily tell whether clauses generated from the EC
1592+
* could be used with the index, so only check for expression
1593+
* match. This might mean we return "true" for a useless index,
1594+
* but that will just cause some wasted planner cycles; it's
1595+
* better than ignoring useful indexes.
1596+
*/
1597+
if ((index->relam != BTREE_AM_OID ||
1598+
list_member_oid(ec->ec_opfamilies, curFamily)) &&
15881599
match_index_to_operand((Node *) em->em_expr, indexcol, index))
15891600
return true;
15901601

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