[SERVER-8447] $query with count and $hint not behaving the same as count() and hint() of cursor Created: 04/Feb/13 Updated: 15/Feb/13 Resolved: 04/Feb/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.2.2, 2.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Chee-Wee | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
OSX, Linux |
||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Steps To Reproduce: | in mongo shell, Doing this db.listing.find( {'p_key': 'DhpPsG'}).count() and db.listing.find({'$query': {'p_key': 'DhpPsG'}}).count() has different result. The former gives result of 1313 while the latter gives 0. -------- Same as for $hint and hint(). Doing this db.listing.find({'$min': {'_id': '5301fc8327f4f0578d70b24ff6bcc8dd', 'created_on': ISODate("2012-12-26T05:14:35.834Z")}, '$query': {'p_key': 'DhpPsG'}}).hint( {'p_key': 1}).sort([("created_on", 1), ("_id", 1)]).explain() uses the index as I expected but doing this db.listing.find({'$min': {'_id': '5301fc8327f4f0578d70b24ff6bcc8dd', 'created_on': ISODate("2012-12-26T05:14:35.834Z")}, '$query': {'p_key': 'DhpPsG'}, '$hint':{'p_key': 1}}).sort([("created_on", 1), ("_id", 1)]).explain() does not use the index as I expected. The result of former is: , { "$maxElement" : 1 } ] the result of latter is: }, |
||||||||
| Participants: | |||||||||
| Description |
|
find({'$query':{...}}).count() has different result as find( {...}).count() Same as for and $hint not behaving the same as count() and hint() of cursor |