[SERVER-12297] Distinct - nscanned for $in and $or greater than nscannedObjects Created: 08/Jan/14  Updated: 17/May/17  Resolved: 31/Jan/14

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

Type: Bug Priority: Minor - P4
Reporter: Jonathan Abrahams Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File server12297.js    
Issue Links:
Related
is related to SERVER-2094 distinct cheat with indexes Closed
is related to SERVER-29244 CLONE - distinct cheat with indexes Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

The following queries generates an anomaly with nscanned:

t = db.distinct_index1
t.drop();
 
for ( i=0; i < 100; ++i ) {
      t.insert( {a: i%10} );
}
t.ensureIndex({a:1});
t.runCommand( "distinct" , { key : 'a' , query : { a : { $in : [2, 4, 6, 8] } } } );
 
{
	"values" : [
		2,
		4,
		6,
		8
	],
	"stats" : {
		"n" : 40,
		"nscanned" : 43,
		"nscannedObjects" : 40,
		"timems" : 12,
		"cursor" : "BtreeCursor a_1"
	},
	"ok" : 1
}
 
t.runCommand( "distinct" , { key : 'a' , query :{ $or: [{a:3}, {a:5}] } } );
 
{
	"values" : [
		3,
		5
	],
	"stats" : {
		"n" : 20,
		"nscanned" : 21,
		"nscannedObjects" : 20,
		"timems" : 0,
		"cursor" : "BtreeCursor a_1"
	},
	"ok" : 1
}

Participants:

 Description   

nscanned for certain indexed queries ($or & $in) returns a different result than nscannedObjects. This is not an issue when using $gt, $lt, $and, etc.



 Comments   
Comment by Jonathan Abrahams [ 31/Jan/14 ]

Looks good in nightly.

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