[SERVER-3493] count command should give indexinfo Created: 27/Jul/11  Updated: 10/Dec/14  Resolved: 15/Oct/14

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

Type: Bug Priority: Major - P3
Reporter: ttt Assignee: David Storch
Resolution: Duplicate Votes: 7
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

centos x64 mongo-10gen-server-1.8.2-mongodb_1


Issue Links:
Related
related to SERVER-10448 Revamp explain() formatting Closed
Operating System: Linux
Participants:

 Description   

> db.index.find().count().explain();
Wed Jul 27 16:51:45 TypeError: db.index.find().count().explain is not a function (shell):1

other ways to call count with explain i have tried also fail similarly.

how do i know if mongod optimizes count query correctly if i can't "explain" it?



 Comments   
Comment by David Storch [ 15/Oct/14 ]

Explain work being done under SERVER-10448 will allow explain to be run on count operations. Closing as a duplicate.

Comment by Nic Cottrell (Personal) [ 12/Aug/14 ]

I'm suddenly getting very slow results for count after upgrading 2.6.3->2.6.4. Query is like:

{ "$query" :
   { "wpm" : { "$gte" : 0.008999999612569809} ,
      "tlc" : { "$in" : [ "slovenia" , "kacin"]} , 
       "lc" : { "$in" : [ ...]}} , 
   "$readPreference" : { "mode" : "secondaryPreferred" , "tags" : [ { "use" : "Unit"}]}
}

Comment by Sylvain Zimmer [ 31/Jan/14 ]

The issue I'm having now is very slow counts on big collections, even if they query only indexed fields by exact values.

It's pretty hard to debug because find().explain() timeouts. If I do find().limit(10).explain() I do see the index being used but it still leaves me wondering what's happening with the counts!

So, some kind of way to debug slow counts besides doing find().explain() would be very helpful.

Thanks,

Comment by Christopher Price [ 01/Dec/11 ]

How do we know for sure that it is using the same index?

Comment by Eliot Horowitz (Inactive) [ 27/Jul/11 ]

In general count() uses the same index as a normal query.
So its the same as find().explain()

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