[SERVER-2845] when using skip, objects still reported as being scanned. Created: 27/Mar/11  Updated: 10/Dec/14  Resolved: 15/Oct/14

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

Type: Bug Priority: Minor - P4
Reporter: Antoine Girbal Assignee: David Storch
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-13946 Consider putting skip stages below fe... Closed
Related
related to SERVER-10448 Revamp explain() formatting Closed
Operating System: ALL
Participants:

 Description   

In following example, collection has 3 matching docs on condition, and is using index to match.
If adding a skip(2), it only returns 1 document.
You would expect nscanned=3 but nscannedObjects should be 1, not 3, since 2 docs are skipped.
Is that just counting bug or are we actually looking at docs, which would make skip very inefficient?

foo:PRIMARY> db.testindex.find({a:5}).skip(2).explain()
{
	"cursor" : "BtreeCursor a_1",
	"nscanned" : 3,
	"nscannedObjects" : 3,
	"n" : 1,
	"millis" : 0,
	"nYields" : 0,
	"nChunkSkips" : 0,
	"isMultiKey" : true,
	"indexOnly" : false,
	"indexBounds" : {
		"a" : [
			[
				5,
				5
			]
		]
	}
}



 Comments   
Comment by David Storch [ 15/Oct/14 ]

This is duplicated by SERVER-13946. Since SERVER-13946 describes the issue in terms of the 2.6 query engine and has been triaged more recently, I am closing this one as a duplicate.

Comment by auto [ 05/Apr/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-2845 add test
Branch: master
https://github.com/mongodb/mongo/commit/1e7801efab0f26d0e73ae83c02028abb5eefc53d

Comment by Aaron Staple [ 05/Apr/11 ]

The object isn't getting loaded. It's a bug in the way nscannedObjects is calculated.

if ( !matcher()>matches(_c>currKey(), _c->currLoc() , &_details ) )

{ // not a match, continue onward if ( _details.loadedObject ) _nscannedObjects++; }

else {
_nscannedObjects++;

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