[SERVER-26113] explain() for aggregations pulls from the plan cache Created: 14/Sep/16  Updated: 30/Apr/19  Resolved: 21/Mar/17

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 3.5.5

Type: Bug Priority: Major - P3
Reporter: Chris Harris Assignee: Nicholas Zolnierz
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Run the following four commands (the last command is repeated twice):

db.test.createIndex({x:1})
db.test.createIndex({y:1})
db.test.explain().aggregate([{$match:{x:1,y:1}}])
db.test.explain().aggregate([{$match:{x:1,y:1}}])

Output of the second .explain() in 3.2.9 is:

> db.test.explain().aggregate([{$match:{x:1,y:1}}])
{
	"waitedMS" : NumberLong(0),
	"stages" : [
		{
			"$cursor" : {
				"query" : {
					"x" : 1,
					"y" : 1
				},
				"queryPlanner" : {
					"plannerVersion" : 1,
					"namespace" : "test.test",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"$and" : [
							{
								"x" : {
									"$eq" : 1
								}
							},
							{
								"y" : {
									"$eq" : 1
								}
							}
						]
					},
					"winningPlan" : {
						"stage" : "CACHED_PLAN",
						"inputStage" : {
							"stage" : "FETCH",
							"filter" : {
								"x" : {
									"$eq" : 1
								}
							},
							"inputStage" : {
								"stage" : "IXSCAN",
								"keyPattern" : {
									"y" : 1
								},
								"indexName" : "y_1",
								"isMultiKey" : false,
								"isUnique" : false,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"y" : [
										"[1.0, 1.0]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				}
			}
		}
	],
	"ok" : 1
}

Sprint: Query 2017-03-27
Participants:
Case:

 Description   

Running an explain for an aggregation pipeline appears to get its output from the plan cache. This is evident by the fact that the first stage in the winning plan is CACHED_PLAN and there are no rejected plans. This seems contrary to documented behavior. This was observed on version 3.2.9 and 3.3.8.



 Comments   
Comment by Githook User [ 21/Mar/17 ]

Author:

{u'username': u'nzolnierzmdb', u'name': u'Nick Zolnierz', u'email': u'nicholas.zolnierz@mongodb.com'}

Message: SERVER-26113 explain() for aggregation request does not propogate to corresponding 'QueryRequest'

Small change to bug fix, and adding explain.js test.

Formatting changes

Missed formatting

Incorporating CR feedback
Branch: master
https://github.com/mongodb/mongo/commit/dd260b0a3bde58530504e982b8f4acd753f71739

Generated at Thu Feb 08 04:11:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.