[SERVER-61658] Last point TS Opt M4: sort(ts)+group(meta.a) Created: 19/Nov/21  Updated: 29/Oct/23  Resolved: 22/Mar/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.0.0-rc0

Type: New Feature Priority: Major - P3
Reporter: Ruslan Abdulkhalikov (Inactive) Assignee: Ruslan Abdulkhalikov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-61659 TS Last Point opt: final test plan re... Closed
Backwards Compatibility: Fully Compatible
Participants:

 Description   

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"}
   }}])



 Comments   
Comment by Githook User [ 22/Mar/22 ]

Author:

{'name': 'Ruslan Abdulkhalikov', 'email': 'ruslan.abdulkhalikov@mongodb.com', 'username': 'rusabd1'}

Message: SERVER-61658 Expand lastpoint sort on time only
Branch: master
https://github.com/mongodb/mongo/commit/540e92a417c16b478acff2a2fc24e34e64dc4ae8

Generated at Thu Feb 08 05:53:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.