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

UNPACK_TS_BUCKET stage includes fields it doesn't need

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Integration

      Was doing some experimentation on the tsbs dataset and I believe I encountered a bug with the UNPACK_TS_BUCKET stage. If you have a $project by a follow $count, the UNPACK_TS_BUCKET stage includes every field in the projection even though these fields aren't needed to produce the final result.

      Query 1:

      {
          "$match" : {
              "time" : {
                  "$lt" : ISODate("2016-01-18T01:49:23Z")
              }
          }
      },
      {
          "$project" : {
              "_id" : 1,
              "tags" : 1,
              "usage_softirq" : 1,
              "usage_steal" : 1,
              "usage_guest" : 1
          }
      },
      {
          "$count" : "count"
      } 

      Query 2:

      {
          "$match" : {
              "time" : {
                  "$lt" : ISODate("2016-01-18T01:49:23Z")
              }
          }
      },
      {
          "$count" : "count"
      } 

      Partial explain diff:

      Query1:

      "inputStage" : {
          "stage" : "UNPACK_TS_BUCKET",
          "planNodeId" : 2,
          "include" : [
              "_id",
              "time",
              "usage_guest",
              "usage_softirq",
              "usage_steal",
              "tags"
          ],
          "computedMetaProjFields" : [ ],
          "includeMeta" : true, 

      Query2:

      "inputStage" : {
          "stage" : "UNPACK_TS_BUCKET",
          "planNodeId" : 2,
          "include" : [
              "time"
          ],
          "computedMetaProjFields" : [ ],
          "includeMeta" : false, 

      Query1 executes in ~5.5s with featureFlagTsInSbeFull while Query2 executes in ~2s with featureFlagTsInSbeFull

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            parker.felix@mongodb.com Parker Felix
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: