-
Type: Task
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
Order of fields in output documents of simple inclusion projection queries is not the same in CQF vs SBE.
Consider the following documents:
{ “_id” : 0, “a1" : { “b1” : 1, “c1" : 1 }, “a2” : { “b2" : 1, “c2” : 1 } } { “_id” : 1, “a2” : { “c2" : 1, “b2” : 1 }, “a1" : { “c1” : 1, “b1" : 1 } }
and the query
{$project: {‘a2.b2’: 1, ‘a1.b1’: 1}}
SBE orders the fields by the order in which they were included in the projection spec, so in both output docs we see "a2" followed by "a1". CQF orders the fields alphabetically, so in both output docs we see "a1" followed be "a2".
Classic does something else; it maintains the order of the fields in the input document. The classic/SBE difference seemed to be approved.
- is related to
-
SERVER-70236 [CQF] Order of fields in output documents of computed projections/addFields changes in CQF
- Backlog