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

Last point TS Opt M4: sort(ts)+group(meta.a)

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible

      Given this query:

      db.coll.aggregate([
         {$sort: {"ts”: 1}},
         {$group: {
           _id: "$meta.a”,
           ts: {$last: "$ts”},
           measureA: {$last: "$measureA"},
           measureB: {$last: "$measureB"}
         }}])
      

      and assuming an index on {meta.a:1, ts:1},

      Expand the $sort into the following to trigger the last point optimization:

      db.coll.aggregate([
         {$sort: {"meta.a":"1, "ts”: 1}},
         {$group: {
           _id: "$meta.a”,
           ts: {$last: "$ts”},
           measureA: {$last: "$measureA"},
           measureB: {$last: "$measureB"}
         }}])
      

            Assignee:
            ruslan.abdulkhalikov@mongodb.com Ruslan Abdulkhalikov (Inactive)
            Reporter:
            ruslan.abdulkhalikov@mongodb.com Ruslan Abdulkhalikov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: