[SERVER-55575] Optimize $group on meta $min/$max on measurements for time-series collections Created: 26/Mar/21  Updated: 29/Oct/23  Resolved: 27/Apr/21

Status: Closed
Project: Core Server
Component/s: Query Planning
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Charlie Swanson Assignee: Svilen Mihaylov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-55624 Track materialized counts and sums fo... Backlog
Backwards Compatibility: Fully Compatible
Sprint: Query Optimization 2021-05-03
Participants:

 Description   

For a time-series collection, we automatically bucket fields and have a control block with the min and max of each, like so:

{ _id: ObjectId(...),
  control: { 
    version: 1, // in case we want to change the format in a later release
    min: { _id: ..., time: ISODate("2020-09-09T16:54:04.174Z"), field0: 0.01, ... },
    max: { _id: ..., time: ISODate("2020-09-09T16:54:04.450Z"), field0: 0.99, ... },
  },
  meta: ...,
  data: { _id: { 0:..., 1: ..., ...},
          time: { 0: ISODate("2020-09-09T16:54:04.174Z"),
                  1: ISODate("2020-09-09T16:54:04.450Z"), ...}, 
          field0: { 0: 0.99, 1: 0.01,...},
          field1: { 2: "high", 42: "low",...}, // Missing fields are omitted
          ...}
}

For a query over that collection like this:

db.example.aggregate([{$group: {_id: "$meta.x", field0: {$max: "$field0"}}}])

We should be able to avoid unpacking or looking at "data" at all.



 Comments   
Comment by Svilen Mihaylov (Inactive) [ 27/Apr/21 ]

https://mongodbcr.appspot.com/761280001/

Comment by Githook User [ 27/Apr/21 ]

Author:

{'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'smihaylov-mongodb'}

Message: SERVER-55575 Optimize $group on meta $min/$max on measurements for time-series collections
Branch: master
https://github.com/mongodb/mongo/commit/67583f907389d0cb6ad00944c64f2ab1d80ef032

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