diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c
index 9132ce235f..92ee08e6ae 100644
--- a/src/backend/optimizer/path/equivclass.c
+++ b/src/backend/optimizer/path/equivclass.c
@@ -1400,11 +1400,9 @@ generate_join_implied_equalities(PlannerInfo *root,
 	}
 
 	/*
-	 * Get all eclasses that mention both inner and outer sides of the join
+	 * Examine all eclasses that mention either side of the join.
 	 */
-	matching_ecs = get_common_eclass_indexes(root, nominal_inner_relids,
-											 outer_relids);
-
+	matching_ecs = get_eclass_indexes_for_relids(root, nominal_join_relids);
 	i = -1;
 	while ((i = bms_next_member(matching_ecs, i)) >= 0)
 	{
