[SERVER-5032] unnecessarily large nScanned occurs during sharded $in queries with sort() and limit() Created: 22/Feb/12  Updated: 07/Mar/14  Resolved: 22/Feb/12

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

Type: Improvement Priority: Minor - P4
Reporter: David Wasserstrum Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PDF File mongolargenScannedduringsortedINqueriesonshards.pdf    
Issue Links:
Depends
Duplicate
duplicates SERVER-3310 Query optimizer should efficiently ha... Closed
Participants:

 Description   

A large number of nScannedObjects occurs when a sharded $in query contains both a limit() and sort() clause.

For example, we have a checkins collection which is sharded by

{uid: 1}

and contains the index

{uid: 1, _id: -1}

. A db.checkins.find({uid: {$in: [400438]}}).limit(2).sort({_id: -1}) will scan just the two documents returned. db.checkins.find({uid: {$in: [400438, 32]}}).limit(2).sort({_id: -1}) will scan thousands of documents.

The attachment walks through the example with an interactive console.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 22/Feb/12 ]

SERVER-3310

Comment by David Wasserstrum [ 22/Feb/12 ]

Yes Aaron. Thank you for bringing SERVER-3310 to our attention. You can resolve this as a duplicate.

Comment by Aaron Staple [ 22/Feb/12 ]

Hi David - would SERVER-3310 cover this for you?

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