Make SelectMergeRule greedily merge all child selects#3850
Make SelectMergeRule greedily merge all child selects#3850g31pranjal wants to merge 14 commits intoFoundationDB:mainfrom
SelectMergeRule greedily merge all child selects#3850Conversation
b262c38 to
006418a
Compare
alecgrieser
left a comment
There was a problem hiding this comment.
The PR description could also probably use a bit more motivation explaining what this is for. This may be a bit harder to add, but I believe the thought was that this should fix some queries that were previously unable to plan due to index matching problems, and it would be nice if those could be added to a yaml test case
...e/src/main/java/com/apple/foundationdb/record/query/plan/cascades/rules/SelectMergeRule.java
Outdated
Show resolved
Hide resolved
.../apple/foundationdb/record/query/plan/cascades/values/translation/RegularTranslationMap.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/com/apple/foundationdb/record/query/plan/cascades/rules/SelectMergeRule.java
Outdated
Show resolved
Hide resolved
...record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/InSource.java
Outdated
Show resolved
Hide resolved
...core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryInJoinPlan.java
Outdated
Show resolved
Hide resolved
| Arguments.of(ImmutableMap.of(250L, 50L, 40L, 10L), LEVEL, List.of(250L, 40L, 50L, 10L, 10L, 1L, 1L)), | ||
| Arguments.of(ImmutableMap.of(250L, 50L, 40L, 10L), PREORDER, List.of(250L, 50L, 10L, 1L, 40L, 10L, 1L)), | ||
| Arguments.of(ImmutableMap.of(250L, 50L, 40L, 10L), ANY, List.of(250L, 50L, 10L, 1L, 40L, 10L, 1L)), | ||
| Arguments.of(ImmutableMap.of(250L, 50L, 40L, 10L), ANY, List.of(250L, 40L, 50L, 10L, 10L, 1L, 1L)), |
There was a problem hiding this comment.
Do you know what happened here? Does it have something the do with the fact that the order of quantifiers (and their children) can be modified by the SelectMergeRule if they don't start in a topologically sorted order?
There was a problem hiding this comment.
I don't know what changed here - but it is definitely not because of the order of the quantifiers as I did try with presereved ordering and that didn't change the result. I think it is the side-effect of complete merging. However, I didn't look deeper as the results are correct for ANY ordering
...c/test/java/com/apple/foundationdb/record/query/plan/cascades/rules/SelectMergeRuleTest.java
Outdated
Show resolved
Hide resolved
SelectMergeRule greedily merge all child selects
📊 Metrics Diff Analysis ReportSummary
ℹ️ About this analysisThis automated analysis compares query planner metrics between the base branch and this PR. It categorizes changes into:
The last category in particular may indicate planner regressions that should be investigated. New QueriesCount of new queries by file:
Plan and Metrics ChangedThese queries experienced both plan and metrics changes. This generally indicates that there was some planner change Total: 23 queries Statistical Summary (Plan and Metrics Changed)
There were no queries with significant regressions detected. Minor Changes (Plan and Metrics Changed)In addition, there were 23 queries with minor changes. Only Metrics ChangedThese queries experienced only metrics changes without any plan changes. If these metrics have substantially changed, Total: 32 queries Statistical Summary (Only Metrics Changed)
There were no queries with significant regressions detected. Minor Changes (Only Metrics Changed)In addition, there were 32 queries with minor changes. |
This PR makes the
SelectMergeRuleto merge all its children select expressions. This improves on the earlier approach that used to merge only certain children that were deemed mergable. A child was considered mergable if there is no correlation pointing to it from other children. Hence, the merge was partial in some sense. The current approach relaxes that constraint. In a nutshell it does the followingtranslationMapand add to the new topselect. Apply the same translation on predicates and put them in topselect.resultValueand put it in the "running"translationMap- to be used by future children.Resolves: #4012