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

Unexpected non-covered query in 3.0 and 2.6 (that is covered in 2.4)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.6.11, 3.0.6
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Operating System:
      ALL

      Description

      Query:

      db.foo.find({"age" : {"$gte" : 21}},{"_id":0, "username":1, "age":1}).explain(true)
      

      Index

      {"username" : 1, "age" : 1}
      

      is not covered in 3.0.6

      > db.foo.find({"age" : {"$gte" : 21}},{"_id":0, "username":1, "age":1}).sort({username:1}).explain(true)
      {
      	"queryPlanner" : {
      		"plannerVersion" : 1,
      		"namespace" : "test.foo",
      		"indexFilterSet" : false,
      		"parsedQuery" : {
      			"age" : {
      				"$gte" : 21
      			}
      		},
      		"winningPlan" : {
      			"stage" : "PROJECTION",
      			"transformBy" : {
      				"_id" : 0,
      				"username" : 1,
      				"age" : 1
      			},
      			"inputStage" : {
      				"stage" : "FETCH",
      				"filter" : {
      					"age" : {
      						"$gte" : 21
      					}
      				},
      				"inputStage" : {
      					"stage" : "IXSCAN",
      					"keyPattern" : {
      						"username" : 1,
      						"age" : 1
      					},
      					"indexName" : "username_1_age_1",
      					"isMultiKey" : false,
      					"direction" : "forward",
      					"indexBounds" : {
      						"username" : [
      							"[MinKey, MaxKey]"
      						],
      						"age" : [
      							"[MinKey, MaxKey]"
      						]
      					}
      				}
      			}
      		},
      		"rejectedPlans" : [ ]
      	},
      	"executionStats" : {
      		"executionSuccess" : true,
      		"nReturned" : 9,
      		"executionTimeMillis" : 0,
      		"totalKeysExamined" : 32,
      		"totalDocsExamined" : 32,
      		"executionStages" : {
      			"stage" : "PROJECTION",
      			"nReturned" : 9,
      			"executionTimeMillisEstimate" : 0,
      			"works" : 33,
      			"advanced" : 9,
      			"needTime" : 23,
      			"needFetch" : 0,
      			"saveState" : 0,
      			"restoreState" : 0,
      			"isEOF" : 1,
      			"invalidates" : 0,
      			"transformBy" : {
      				"_id" : 0,
      				"username" : 1,
      				"age" : 1
      			},
      			"inputStage" : {
      				"stage" : "FETCH",
      				"filter" : {
      					"age" : {
      						"$gte" : 21
      					}
      				},
      				"nReturned" : 9,
      				"executionTimeMillisEstimate" : 0,
      				"works" : 33,
      				"advanced" : 9,
      				"needTime" : 23,
      				"needFetch" : 0,
      				"saveState" : 0,
      				"restoreState" : 0,
      				"isEOF" : 1,
      				"invalidates" : 0,
      				"docsExamined" : 32,
      				"alreadyHasObj" : 0,
      				"inputStage" : {
      					"stage" : "IXSCAN",
      					"nReturned" : 32,
      					"executionTimeMillisEstimate" : 0,
      					"works" : 32,
      					"advanced" : 32,
      					"needTime" : 0,
      					"needFetch" : 0,
      					"saveState" : 0,
      					"restoreState" : 0,
      					"isEOF" : 1,
      					"invalidates" : 0,
      					"keyPattern" : {
      						"username" : 1,
      						"age" : 1
      					},
      					"indexName" : "username_1_age_1",
      					"isMultiKey" : false,
      					"direction" : "forward",
      					"indexBounds" : {
      						"username" : [
      							"[MinKey, MaxKey]"
      						],
      						"age" : [
      							"[MinKey, MaxKey]"
      						]
      					},
      					"keysExamined" : 32,
      					"dupsTested" : 0,
      					"dupsDropped" : 0,
      					"seenInvalidated" : 0,
      					"matchTested" : 0
      				}
      			}
      		},
      		"allPlansExecution" : [ ]
      	},
      	"serverInfo" : {
      		"host" : "Joannas-MacBook-Pro.local",
      		"port" : 27017,
      		"version" : "3.0.6",
      		"gitVersion" : "1ef45a23a4c5e3480ac919b28afcba3c615488f2"
      	},
      	"ok" : 1
      }
      

      However it is covered in 2.4.14

      replset:PRIMARY> db.foo.find({"age" : {"$gte" : 21}},{"_id":0, "username":1, "age":1}).sort({username:1}).explain(true)
      {
      	"cursor" : "BtreeCursor username_1_age_1",
      	"isMultiKey" : false,
      	"n" : 9,
      	"nscannedObjects" : 0,
      	"nscanned" : 10,
      	"nscannedObjectsAllPlans" : 11,
      	"nscannedAllPlans" : 21,
      	"scanAndOrder" : false,
      	"indexOnly" : true,
      	"nYields" : 0,
      	"nChunkSkips" : 0,
      	"millis" : 0,
      	"indexBounds" : {
      		"username" : [
      			[
      				{
      					"$minElement" : 1
      				},
      				{
      					"$maxElement" : 1
      				}
      			]
      		],
      		"age" : [
      			[
      				21,
      				1.7976931348623157e+308
      			]
      		]
      	},
      	"allPlans" : [
      		{
      			"cursor" : "BtreeCursor username_1_age_1",
      			"n" : 9,
      			"nscannedObjects" : 0,
      			"nscanned" : 10,
      			"indexBounds" : {
      				"username" : [
      					[
      						{
      							"$minElement" : 1
      						},
      						{
      							"$maxElement" : 1
      						}
      					]
      				],
      				"age" : [
      					[
      						21,
      						1.7976931348623157e+308
      					]
      				]
      			}
      		},
      		{
      			"cursor" : "BasicCursor",
      			"n" : 0,
      			"nscannedObjects" : 11,
      			"nscanned" : 11,
      			"indexBounds" : {
       
      			}
      		}
      	],
      	"oldPlan" : {
      		"cursor" : "BtreeCursor username_1_age_1",
      		"indexBounds" : {
      			"username" : [
      				[
      					{
      						"$minElement" : 1
      					},
      					{
      						"$maxElement" : 1
      					}
      				]
      			],
      			"age" : [
      				[
      					21,
      					1.7976931348623157e+308
      				]
      			]
      		}
      	},
      	"server" : "Joannas-MacBook-Pro.local:27018"
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rassi J Rassi
              Reporter:
              joanna.cheng Joanna Cheng
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: