[SERVER-3965] $maxScan only works for initial query Created: 27/Sep/11  Updated: 05/May/14  Resolved: 22/Jan/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 1.8.3, 2.0.0, 2.4.7
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Barrie Segal Assignee: Unassigned
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Operating System: ALL
Participants:

 Description   

This came from http://groups.google.com/group/mongodb-user/browse_thread/thread/d8940067b89cb839

$maxScan does not return expected results when it is >100

To reproduce:
> for(i=0; i<50000; i++){db.mxscan.save(

{'ts':i, 'nr':i%47}

);}
> count = 0; db.mxscan.find()._addSpecial( "$maxScan" , 101 ).forEach( function

{ count += 1; } ); print(count);
50000
> count = 0; db.mxscan.find()._addSpecial( "$maxScan" , 100 ).forEach( function { count += 1; }

); print(count);
100



 Comments   
Comment by Scott Hernandez (Inactive) [ 22/Jan/14 ]

This has gone away with the current version (2.5.x dev) of the query code. With the new query system this is no longer an issue:

...
> db.mxscan.count()
50000
> count = 0; db.mxscan.find()._addSpecial( "$maxScan" , 101 ).forEach( function(i) { count += 1; } ); print(count);
101
> count = 0; db.mxscan.find()._addSpecial( "$maxScan" , 100 ).forEach( function(i) { count += 1; } ); print(count);
100
> count = 0; db.mxscan.find()._addSpecial( "$maxScan" , 105 ).forEach( function(i) { count += 1; } ); print(count);
105

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