Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-70234

[CQF] Order of fields in output documents of simple inclusion projection queries is not the same in CQF vs SBE

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • Query Optimization

    Description

      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.

      Attachments

        Activity

          People

            backlog-query-optimization Backlog - Query Optimization
            hana.pearlman@mongodb.com Hana Pearlman
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: