-
Type:
Improvement
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Often an expression accesses the same fileds multiple times, or even different fields from the same BSON object that require a linear scanning of the fields. We could improve the time spent by:
- in the stage builder, inspect all function calls to getField and collect a map of slotId -> field
- if more than one field is accessed, or if a field is accessed more than once, allocate a local $let x = getMultiFields(slot, "field1", "field2" ...)
- the getMultiFields would do a single linear scan of the fields and return a new Object type with just the requested fields; the SBE Object type has an array of preparsed fields, that could be improved by having a map on the side to guarantee a fast retrieval
- the getField function calls would be modified to point to the new "x" variable instead of the original slot