[SERVER-79403] Avoid implementing stacks of EvaluationNode as stacks of SBE project operators Created: 27/Jul/23 Updated: 08/Dec/23 Resolved: 08/Dec/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.3.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Anton Korshunov | Assignee: | Milena Ivanova |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | M2 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Assigned Teams: |
Query Optimization
|
||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||
| Sprint: | QO 2023-09-04, QO 2023-09-18, QO 2023-10-02, QO 2023-10-16, QO 2023-10-30, QO 2023-11-13, QO 2023-11-27, QO 2023-12-11 | ||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
Currently in Bonsai each projection is implemented as a separate EvaluationNode. We have an existing optimisation which tries to convert each projection into a SargableNode, and push it down into collection/index scan. However, if the projections contains residual expressions, we may end up with a physical plan containing a stack of EvaluationNodes, which eventually will be lowered into a stack of SBE project operators. We will need to investigate performance overhead of having a stack of projections in an SBE plan and try to optimize it by merging the EvalNodes into a single evaluation node (a new type of an ABT node) with combined projections. |
| Comments |
| Comment by Githook User [ 07/Dec/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Milena Ivanova', 'email': 'milena.ivanova@mongodb.com', 'username': 'mivanova3'}Message: GitOrigin-RevId: 8c6086c3dc36dc1228db74a42897f7d6bf196fcf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Milena Ivanova [ 24/Nov/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Local tests with mongo-perf, measurement ops_per_sec:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Milena Ivanova [ 26/Oct/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Performance of the prototype implementing the physical MultiEvalNode and a post-memo rewrite, master branch from 24.10:
Using the executionTimeMillisEstimate measurement for each SBE stage, the measured times only for projection stages are as follows:
Notice, that the overall improvement of the query execution time in the prototype is bigger than the improvement seen only in the merged projection stages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Milena Ivanova [ 22/Aug/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
As a first step of this task I ran a benchmark evaluation comparing a stack of SBE projection stages as currently created from Bonsai with a single SBE projection combining the computation of the same expressions.
{_id: i, a: { b: i * 5, c: "xx", d: 1.234}, k: {l: "LLL", m:"MMM"}, x: {y: {z: "xyz".repeat(3)}}, p: { q: 5, r: 4.567}} The collection sizes were 10K, 100K, and 1M documents.
Q1. db.coll.find({}, {f1: "$a.b", f2: “$k.l” }) Q2. db.coll.find({}, {f1: "$a.b", f2: “$k.l”, f3: “$p.q"}) Q3. db.coll.find({}, {f1: "$a.b", f2: “$k.l”, f3: “$p.q”, f4: “$x.y"})
Current Bonsai:
Modified query plan with a projection stage with multiple expressions:
Each query was run 12 times and the average time taken excluding the the smallest and the largest values. The projection time excludes the top-level projection with the let expression and considers only projections extracting the subfields.
|