Skip to content

Commit fa86238

Browse files
committed
Speed up match_eclasses_to_foreign_key_col() when there are many ECs.
Check ec_relids before bothering to iterate through the EC members. On a perhaps extreme, but still real-world, query in which match_eclasses_to_foreign_key_col() accounts for the bulk of the planner's runtime, this saves nearly 40% of the runtime. It's a bit of a stopgap fix, but it's simple enough to be back-patched to 9.6 where this code came in; so let's do that. David Rowley Discussion: https://postgr.es/m/6970.1545327857@sss.pgh.pa.us
1 parent d26a810 commit fa86238

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/backend/optimizer/path/equivclass.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,14 @@ match_eclasses_to_foreign_key_col(PlannerInfo *root,
20522052
continue;
20532053
/* Note: it seems okay to match to "broken" eclasses here */
20542054

2055+
/*
2056+
* If eclass visibly doesn't have members for both rels, there's no
2057+
* need to grovel through the members.
2058+
*/
2059+
if (!bms_is_member(var1varno, ec->ec_relids) ||
2060+
!bms_is_member(var2varno, ec->ec_relids))
2061+
continue;
2062+
20552063
foreach(lc2, ec->ec_members)
20562064
{
20572065
EquivalenceMember *em = (EquivalenceMember *) lfirst(lc2);

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