[DOCS-6306] "executionStats" is not generated for aggregate queries but documentation says otherwise Created: 01/Oct/15  Updated: 24/Jul/17  Resolved: 19/Nov/15

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: mongodb-3.0
Fix Version/s: 01112017-cleanup, 3.5.5

Type: Task Priority: Major - P3
Reporter: Steven Hand Assignee: Ravind Kumar (Inactive)
Resolution: Done Votes: 0
Labels: query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

3.0.6


Issue Links:
Related
is related to SERVER-19758 Add "executionStats" and "allPlansExe... Closed
Participants:
Days since reply: 8 years, 12 weeks, 6 days ago
Epic Link: DOCS: 3.6 Server

 Description   

The documentation for db.collection.explain() states that
Returns information on the query plan for the following operations: aggregate(); count(); find(); group(); remove(); and update() methods.

However, the "executionStats" is not produced for aggregate. I understand that explain output "aggregate" only includes the "queryPlanner" output.

It may not be produced for all the commands in the above list of methods and all variants of the parameter values: "queryPlanner", "executionStats", and "allPlansExecution". Someone should verify.



 Comments   
Comment by Ravind Kumar (Inactive) [ 19/Nov/15 ]

https://github.com/mongodb/docs/pull/2417

Comment by Githook User [ 19/Nov/15 ]

Author:

{u'username': u'rkumar-mongo', u'name': u'ravind', u'email': u'ravind.kumar@10gen.com'}

Message: DOCS-6306 - explain().aggregate() only returns queryPlanner verbosity mode at this time

Signed-off-by: kay <kay.kim@10gen.com>
Branch: v3.0
https://github.com/mongodb/docs/commit/0c1eb4e0030e811ee8aa8929b9bb9e603b979186

Comment by Githook User [ 19/Nov/15 ]

Author:

{u'username': u'rkumar-mongo', u'name': u'ravind', u'email': u'ravind.kumar@10gen.com'}

Message: DOCS-6306 - explain().aggregate() only returns queryPlanner verbosity mode at this time

Signed-off-by: kay <kay.kim@10gen.com>
Branch: master
https://github.com/mongodb/docs/commit/59c70ad7e11680c15b334e6d6a2287aa4bf00d35

Comment by Steven Hand [ 01/Oct/15 ]

Here's an example of this issue using the blog collection from the MongoDB Java M101 class

> version()
3.0.6
> db.version()
3.0.6
> var exp = db.posts.explain("executionStats");
> exp.find()
{
	"queryPlanner" : {
		"plannerVersion" : 1,
		"namespace" : "blog.posts",
		"indexFilterSet" : false,
		"parsedQuery" : {
			"$and" : [ ]
		},
		"winningPlan" : {
			"stage" : "COLLSCAN",
			"filter" : {
				"$and" : [ ]
			},
			"direction" : "forward"
		},
		"rejectedPlans" : [ ]
	},
	"executionStats" : {
		"executionSuccess" : true,
		"nReturned" : 1000,
		"executionTimeMillis" : 0,
		"totalKeysExamined" : 0,
		"totalDocsExamined" : 1000,
		"executionStages" : {
			"stage" : "COLLSCAN",
			"filter" : {
				"$and" : [ ]
			},
			"nReturned" : 1000,
			"executionTimeMillisEstimate" : 0,
			"works" : 1002,
			"advanced" : 1000,
			"needTime" : 1,
			"needFetch" : 0,
			"saveState" : 7,
			"restoreState" : 7,
			"isEOF" : 1,
			"invalidates" : 0,
			"direction" : "forward",
			"docsExamined" : 1000
		}
	},
	"serverInfo" : {
		"host" : "Stevens-MacBook-Pro.local",
		"port" : 27017,
		"version" : "3.0.6",
		"gitVersion" : "1ef45a23a4c5e3480ac919b28afcba3c615488f2"
	},
	"ok" : 1
}
> exp.aggregate([{$project:{_id:0,"comments.author":1}},{$unwind:"$comments"},{$group:{_id:{author:"$comments.author"},count:{$sum:1}}},{$sort:{count:1}},{$limit:5}])
{
	"stages" : [
		{
			"$cursor" : {
				"query" : {
					
				},
				"fields" : {
					"comments.author" : 1,
					"_id" : 0
				},
				"queryPlanner" : {
					"plannerVersion" : 1,
					"namespace" : "blog.posts",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"$and" : [ ]
					},
					"winningPlan" : {
						"stage" : "COLLSCAN",
						"filter" : {
							"$and" : [ ]
						},
						"direction" : "forward"
					},
					"rejectedPlans" : [ ]
				}
			}
		},
		{
			"$project" : {
				"_id" : false,
				"comments" : {
					"author" : true
				}
			}
		},
		{
			"$unwind" : "$comments"
		},
		{
			"$group" : {
				"_id" : {
					"author" : "$comments.author"
				},
				"count" : {
					"$sum" : {
						"$const" : 1
					}
				}
			}
		},
		{
			"$sort" : {
				"sortKey" : {
					"count" : 1
				},
				"limit" : NumberLong(5)
			}
		}
	],
	"ok" : 1
}
> 

Generated at Thu Feb 08 07:52:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.