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

Duplicate predicates in query plan for time-series collection

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Integration
    • ALL
    • Hide
      db.createCollection("demo", {timeseries: {timeField: "time", granularity: "minutes"}})
      db.adminCommand({enableSharding: "test"})
      db.adminCommand({shardCollection: "test.demo", key: {time: 1}})
      
      db.demo.insert({time: ISODate("2021-10-01T21:00:00Z")})
      db.demo.find({time: ISODate("2021-10-01T21:00:00Z")}).explain()
      
      Show
      db.createCollection( "demo" , {timeseries: {timeField: "time" , granularity: "minutes" }}) db.adminCommand({enableSharding: "test" }) db.adminCommand({shardCollection: "test.demo" , key: {time: 1}}) db.demo.insert({time: ISODate( "2021-10-01T21:00:00Z" )}) db.demo.find({time: ISODate( "2021-10-01T21:00:00Z" )}).explain()
    • QO 2021-11-15, QO 2021-11-29, QO 2021-12-13, QO 2021-12-27, QO 2022-01-10, QO 2022-01-24, QO 2022-02-07, QO 2022-02-21, QO 2022-03-07, QO 2022-03-21, QO 2022-04-04, QO 2022-04-18, QO 2022-05-02, QO 2022-05-16, QO 2022-05-30, QO 2022-06-13, QO 2022-06-27, QO 2022-07-11, QO 2022-07-25, QO 2022-08-08, QO 2022-08-22, QO 2022-09-05, QO 2022-09-19, QO 2022-10-03, QE 2022-10-17

      Querying a time-series collection produces a confusing query plan that has each $match predicate duplicated twice.

      "winningPlan" : {
      	"stage" : "SHARDING_FILTER",
      	"inputStage" : {
      		"stage" : "FETCH",
      		"filter" : {
      			"$and" : [
      				{
      					"_id" : {
      						"$lte" : ObjectId("615776d0ffffffffffffffff")
      					}
      				},
      				{
      					"_id" : {
      						"$lte" : ObjectId("615776d0ffffffffffffffff")
      					}
      				},
      				{
      					"_id" : {
      						"$gte" : ObjectId("615625500000000000000000")
      					}
      				},
      				{
      					"_id" : {
      						"$gte" : ObjectId("615625500000000000000000")
      					}
      				},
      				{
      					"control.max.time" : {
      						"$_internalExprGte" : ISODate("2021-10-01T21:00:00Z")
      					}
      				},
      				{
      					"control.max.time" : {
      						"$_internalExprGte" : ISODate("2021-10-01T21:00:00Z")
      					}
      				}
      			]
      		},
      		"inputStage" : {
      			"stage" : "IXSCAN",
      			"keyPattern" : {
      				"control.min.time" : 1
      			},
      			"indexName" : "control.min.time_1",
      			"isMultiKey" : false,
      			"multiKeyPaths" : {
      				"control.min.time" : [ ]
      			},
      			"isUnique" : false,
      			"isSparse" : false,
      			"isPartial" : false,
      			"indexVersion" : 2,
      			"direction" : "forward",
      			"indexBounds" : {
      				"control.min.time" : [
      					"[new Date(1633035600000), new Date(1633122000000)]"
      				]
      			}
      		}
      	}
      }
      

       

       

            Assignee:
            naama.bareket@mongodb.com Naama Bareket
            Reporter:
            rui.liu@mongodb.com Rui Liu
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: