v7-0002-Revert-one-of-the-optimizations.patch
application/octet-stream
Filename: v7-0002-Revert-one-of-the-optimizations.patch
Type: application/octet-stream
Part: 10
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v7-0002
Subject: Revert one of the optimizations
| File | + | − |
|---|---|---|
| src/backend/optimizer/path/equivclass.c | 12 | 9 |
From ac54a3effc0369862cab82b164d28d30e7a2d2fe Mon Sep 17 00:00:00 2001
From: Yuya Watari <watari.yuya@gmail.com>
Date: Mon, 5 Sep 2022 17:17:13 +0900
Subject: [PATCH v7 2/3] Revert one of the optimizations
This commit reverts one of our optimizations.
This function enumerates EquivalenceMembers in the given
EquivalenceClass and returns true if there is a chance of merging. This
check is accomplished by finding EMs where
"bms_overlap(cur_em->em_relids, relids)" is false. In most cases, we
reach such EMs early in the loop. Therefore, performing our newly
introduced optimization technique is excessive here, and we revert the
change.
---
src/backend/optimizer/path/equivclass.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c
index 2b04b67b14..5f0d2bafd4 100644
--- a/src/backend/optimizer/path/equivclass.c
+++ b/src/backend/optimizer/path/equivclass.c
@@ -3261,8 +3261,8 @@ eclass_useful_for_merging(PlannerInfo *root,
EquivalenceClass *eclass,
RelOptInfo *rel)
{
- Bitmapset *matching_ems;
Relids relids;
+ int i;
Assert(!eclass->ec_merged);
@@ -3293,15 +3293,18 @@ eclass_useful_for_merging(PlannerInfo *root,
if (bms_is_subset(eclass->ec_relids, relids))
return false;
- /* Find the EquivalenceMember for relids */
- matching_ems = get_ecmember_indexes(root, eclass, relids, false, false);
+ /* To join, we need a member not in the given rel */
+ i = -1;
+ while ((i = bms_next_member(eclass->ec_nonchild_indexes, i)) >= 0)
+ {
+ EquivalenceMember *cur_em =
+ list_nth_node(EquivalenceMember, root->eq_members, i);
- /*
- * If there are any other non-child members besides matching_ems then we
- * have a chance at merging.
- */
- if (bms_nonempty_difference(eclass->ec_nonchild_indexes, matching_ems))
- return true;
+ Assert(!cur_em->em_is_child); /* ignore children here */
+
+ if (!bms_overlap(cur_em->em_relids, relids))
+ return true;
+ }
return false;
}
--
2.35.3.windows.1