[SERVER-3268] Attempting to count() a date query causes cursor to timeout Created: 15/Jun/11  Updated: 29/May/12  Resolved: 02/Sep/11

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

Type: Bug Priority: Major - P3
Reporter: Wes Widner Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB 1.8.1


Issue Links:
Related
related to SERVER-2274 Performance of count() on range check... Closed
Operating System: ALL
Participants:

 Description   

Querying a date with $gt and then attempting to run count() on the resulting cursor hangs.
Ex: db.file.find({datemodified:{$gt:new Date(1219399422000)}}).limit(10).count();



 Comments   
Comment by Eliot Horowitz (Inactive) [ 25/Jun/11 ]

Can you run an explain on that query from the shell?

Comment by Scott Hernandez (Inactive) [ 23/Jun/11 ]

Counts don't run on cursors. The count method at the end of that line issues a separate command (there is never a cursor created) to the server.

In this case you want to call count(true) in the shell to apply the limit otherwise it will get the total count for the query (ignoring the limit).

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