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

Optimize $group on meta $min/$max on measurements for time-series collections

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.0-rc0
    • Affects Version/s: None
    • Component/s: Query Planning
    • None
    • Fully Compatible
    • Query Optimization 2021-05-03

      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.

            Assignee:
            svilen.mihaylov@mongodb.com Svilen Mihaylov (Inactive)
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: