[SERVER-12829] adding projection causes multiKey index query fall back to collection scan Created: 21/Feb/14  Updated: 11/Jul/16  Resolved: 25/Feb/14

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

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: David Storch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

test@local(2.6.0-rc0) > db.multi.find({m:99999}).explain()
{
	"cursor" : "BtreeCursor m_1",
	"isMultiKey" : true,
	"n" : 0,
	"nscannedObjects" : 0,
	"nscanned" : 0,
	"nscannedObjectsAllPlans" : 0,
	"nscannedAllPlans" : 0,
	"scanAndOrder" : false,
	"indexOnly" : false,
	"nYields" : 0,
	"nChunkSkips" : 0,
	"millis" : 0,
	"indexBounds" : {
		"m" : [
			[
				99999,
				99999
			]
		]
	},
	"server" : "asyasmacbook.local:27017",
	"filterSet" : false
}
test@local(2.6.0-rc0) > db.multi.find({m:99999},{_id:0,m:1}).explain()
{
	"cursor" : "BasicCursor",
	"isMultiKey" : false,
	"n" : 0,
	"nscannedObjects" : 102,
	"nscanned" : 102,
	"nscannedObjectsAllPlans" : 105,
	"nscannedAllPlans" : 105,
	"scanAndOrder" : false,
	"indexOnly" : false,
	"nYields" : 0,
	"nChunkSkips" : 0,
	"millis" : 0,
	"server" : "asyasmacbook.local:27017",
	"filterSet" : false
}
test@local(2.6.0-rc0) > db.multi.find({m:99999},{_id:0,m:1}).explain(true)
{
	"cursor" : "BasicCursor",
	"isMultiKey" : false,
	"n" : 0,
	"nscannedObjects" : 102,
	"nscanned" : 102,
	"nscannedObjectsAllPlans" : 105,
	"nscannedAllPlans" : 105,
	"scanAndOrder" : false,
	"indexOnly" : false,
	"nYields" : 0,
	"nChunkSkips" : 0,
	"millis" : 0,
	"allPlans" : [
		{
			"cursor" : "BasicCursor",
			"isMultiKey" : false,
			"n" : 0,
			"nscannedObjects" : 102,
			"nscanned" : 102,
			"scanAndOrder" : false,
			"indexOnly" : false,
			"nChunkSkips" : 0
		},
		{
			"cursor" : "BtreeCursor m_1",
			"isMultiKey" : true,
			"n" : 3,
			"nscannedObjects" : 3,
			"nscanned" : 3,
			"scanAndOrder" : false,
			"indexOnly" : false,
			"nChunkSkips" : 0,
			"indexBounds" : {
				"m" : [
					[
						1,
						1
					]
				]
			}
		}
	],
	"server" : "asyasmacbook.local:27017",
	"filterSet" : false,
	"stats" : {
		"type" : "PROJECTION",
		"works" : 104,
		"yields" : 0,
		"unyields" : 0,
		"invalidates" : 0,
		"advanced" : 0,
		"needTime" : 0,
		"needFetch" : 0,
		"isEOF" : 1,
		"children" : [
			{
				"type" : "COLLSCAN",
				"works" : 104,
				"yields" : 0,
				"unyields" : 0,
				"invalidates" : 0,
				"advanced" : 0,
				"needTime" : 103,
				"needFetch" : 0,
				"isEOF" : 1,
				"docsTested" : 102,
				"children" : [ ]
			}
		]
	}
}



 Comments   
Comment by Githook User [ 25/Feb/14 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-12796 SERVER-12829 SERVER-12830 better plan ranking in the case of EOF or zero results produced

If the winning plan returns zero results but does not hit EOF, then we no longer cache it.

Fixes a bug which would allow plans that did not hit EOF in the multi plan runner to be chosen over EOF plans.
Branch: master
https://github.com/mongodb/mongo/commit/8bf16f9e54e61a6befa791a6378ffdd06ad35a5b

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