Open EmilBode opened 6 years ago
Same problem here. A "count" operation that was working properly stopped working after update to R 3.5.1 and mongolite 2.0.
library(mongolite) m <- mongo(collection = "RealizedRouteCollection", db=mongoDB, url=mongoUrl) m$count() Error: Failed to send "aggregate" command with database "MongoDBDatabase": socket error or timeout
It was working properly before the updates. While the error persists I've found a workaround getting the count from the collection info, with the following code:
info <- m$info() return (info$stats$count)
This returns instantly.
Thanks for the workaround, I overlooked info()
In the latest version of the c driver, the old mongoc_collection_count api was deprecated and now there are 2 api's to perform a count:
I am using the first one, but perhaps there should be an option to use the estimated count instead?
@ajdavis is it expected that mongoc_collection_count_documents is slow?
Good catch. Yes, it is expected that count_documents is slower than estimated_document_count.
OK so I'll add an option to get the estimated count (I guess that's what users are expecting here).
I recommend you follow the same path as libmongoc and other MongoDB drivers: deprecate or remove "count", add "estimatedDocumentCount" and "countDocuments".
On Wed, Sep 12, 2018 at 10:19 AM Jeroen Ooms notifications@github.com wrote:
OK so I'll add an option to get the estimated count (I guess that's what users are expecting here).
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jeroen/mongolite/issues/153#issuecomment-420665456, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFIheUJcnmGQ7BO7WuMNtdZsP4qg5uhks5uaRfqgaJpZM4WhBqt .
Hello, Do you have any updates on this issue? Same problem here.
Hi I working in transactional collections and this have more than 10millons of documents. use a estimated count is very usefull. Jeroen, are you going to add this option ? thks, mongolite is great to R
I guess since the new count api was implemented, I'm having an issue where count() takes a long time to complete. My collection has 1739040 documents, of average size ~ 15kB, and runs in a docker setup. Using the mongo API-itself db.collection.count() returns right away, but when using the mongolite-interface it takes a few minutes. It looks like a full query of some kind is executed, instead of using stored metadata. I guess the new setup is more resistant to errors, but I'm often simply using count() as a quick check if I have a working connection to the right database, where I'd like a quick result. Is this a bug, or could we get back the old count?
Details of setup:
When the process is busy, db.currentOp() gives the following output: