[SERVER-12935] explain output is inaccurate Created: 27/Feb/14  Updated: 11/Jul/16  Resolved: 03/Mar/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.0-rc0
Fix Version/s: 2.6.0-rc1

Type: Bug Priority: Minor - P4
Reporter: Stefan Meyer-Kahlen [X] Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: coveredIndex, indexing, query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

In 2.4.9 it worked fine, 2.6.0-rc queries ineffiecently

See here for full details:
http://stackoverflow.com/questions/22051516/why-is-mongodb-using-scanandorder-here



 Comments   
Comment by Benety Goh [ 04/Mar/14 ]

This is the git hash which fixed the issue:

51300745542e7df3b0864069079e74114c0c42c6

https://github.com/mongodb/mongo/commit/51300745542e7df3b0864069079e74114c0c42c6

planner_analysis.cpp:

https://github.com/mongodb/mongo/commit/51300745542e7df3b0864069079e74114c0c42c6#diff-d666e08e8935b33da88ec280328db4c6L301

Comment by Githook User [ 03/Mar/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-12935 override OR child indexOnly when explaining non-covered queries
Branch: master
https://github.com/mongodb/mongo/commit/cd1cdfcce54d4c0e06aed61b214c383edcae4b02

Comment by Daniel Pasette (Inactive) [ 01/Mar/14 ]

Thanks for the report stefan. I reproduced your issue with 2.6.0-rc0. The scanAndOrder problem is now fixed as of git hash: 2bf41261b20a02f06ec5ad7281f3c16e0b3d7fc3. We'll find out which commit changed the behavior.

While repro'ing, I noticed a couple different minor issues with the explain output. It shows, nscannedObjects: 0, indexOnly: true in the beginning of the explain output (clauses), even thought the summary in "QueryOptimizerCursor" is correct.

> for (i=0; i < 100; i++) { db.z.insert({name: i+'stefan', type:'bli', endMS: new ISODate()});sleep(5);}
> db.z.ensureIndex({name:1,endMS:-1,type:1})
> db.z.find({name:"1stefan",type:"bli",endMS:{$lt:new ISODate()}}).sort({endMS:-1}).explain()
{
	"clauses" : [
		{
			"cursor" : "BtreeCursor name_1_endMS_-1_type_1",
			"isMultiKey" : false,
			"n" : 1,
===>		"nscannedObjects" : 0,
			"nscanned" : 1,
			"scanAndOrder" : false,
===>		"indexOnly" : true,
			"nChunkSkips" : 0,
			"indexBounds" : {
				"name" : [
					[
						"1stefan",
						"1stefan"
					]
				],
				"endMS" : [
					[
						ISODate("2014-03-01T23:34:33.998Z"),
						true
					]
				],
				"type" : [
					[
						"bli",
						"bli"
					]
				]
			}
		}
	],
	"cursor" : "QueryOptimizerCursor",
	"n" : 1,
	"nscannedObjects" : 1,
	"nscanned" : 1,
	"nscannedObjectsAllPlans" : 1,
	"nscannedAllPlans" : 1,
	"scanAndOrder" : false,
	"nYields" : 0,
	"nChunkSkips" : 0,
	"millis" : 0,
	"server" : "DANIELs-MacBook-Pro-2.local:27017",
	"filterSet" : false
}

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