jeroen / mongolite

Fast and Simple MongoDB Client for R
https://jeroen.github.io/mongolite/
284 stars 64 forks source link

mongolite doesn't read the index and read queries are slow #222

Open evafadar opened 3 years ago

evafadar commented 3 years ago

I have created a mongodb database using mongolite and I create index on the _row key on the database using following command:

collection$index(add = '{"_row" : 1}')

when I query a document via Robo3T program with the db.getCollection('collection').find({"_row": "ENSG00000197616"}) command, my index works and it takes less than a second to query the data.

Screenshot (86)

This is also the case when I query the data using pymongo package in python.

Screenshot (88)

Surprisingly, when I perform the same query with mongolite, it takes more than 10 seconds to query data: system.time(collection$find(query = '{"_row": "ENSG00000197616"}'))

user system elapsed 12.221 0.005 12.269

I think this can only come from mongolite package, otherwise, it wouldn't work on the other programs as well.

Any input is highly appreciated!