-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
15
One of the areas in which SBE's performance can be improved is by eliminating repeated path traversals. This is evident in $or queries such as:
"$or" : [ { "a" : 1, "b" : 2 }, { "a" : 2, "b" : 3 } ]
The SBE plan is as follows:
[1] filter {s30} [1] nlj [s4, s5] [s4, s5] left [1] scan s4 s5 none none none none [] @"7b34d685-f43c-4e59-86ad-bdf5f77c6234" true false right [1] limit 1 [1] union [s30] [ [s28] [1] project [s28 = true] [1] filter {s16} [1] limit 1 [1] union [s16] [ [s14] [1] project [s14 = false] [1] filter {! fillEmpty (s9, false)} [1] traverse s9 s8 s6 {s9 || s8} {s9} 1 from [1] project [s6 = getField (s4, "a")] [1] limit 1 [1] coscan in [1] project [s8 = fillEmpty (s6 == s7, false)] [1] limit 1 [1] coscan , [s15] [1] project [s15 = fillEmpty (s13, false)] [1] traverse s13 s12 s10 {s13 || s12} {s13} 1 from [1] project [s10 = getField (s4, "b")] [1] limit 1 [1] coscan in [1] project [s12 = fillEmpty (s10 == s11, false)] [1] limit 1 [1] coscan ] , [s29] [1] project [s29 = s27] [1] limit 1 [1] union [s27] [ [s25] [1] project [s25 = false] [1] filter {! fillEmpty (s20, false)} [1] traverse s20 s19 s17 {s20 || s19} {s20} 1 from [1] project [s17 = getField (s4, "a")] [1] limit 1 [1] coscan in [1] project [s19 = fillEmpty (s17 == s18, false)] [1] limit 1 [1] coscan , [s26] [1] project [s26 = fillEmpty (s24, false)] [1] traverse s24 s23 s21 {s24 || s23} {s24} 1 from [1] project [s21 = getField (s4, "b")] [1] limit 1 [1] coscan in [1] project [s23 = fillEmpty (s21 == s22, false)] [1] limit 1 [1] coscan ] ]
In the above plan, we perform multiple getField lookups for "a" and "b", one for each branch of the $or. This ticket tracks to investigate eliminating such repeated path lookups when constructing SBE plans (credit to nikita.lapkov@mongodb.com for the idea!)
- related to
-
SERVER-69510 Make SBE Stage Builder for match expressions use ABT
- Closed
-
SERVER-69616 Use expressions instead of stages for logical operations in SBE
- Closed