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

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0.0-rc0
    • Component/s: Query Planning
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      Query Optimization 2021-05-03

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              svilen.mihaylov Svilen Mihaylov
              Reporter:
              charlie.swanson Charlie Swanson
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: