I have a database find query which returns 150k documents where each document contains three integer fields and one datetime field. The following code attempts to create a list from the cursor object. Iterating the cursor is incredibly slow - about 80 seconds! The same operation via the C++ drivers is orders of magnitude faster - it must be an issue with PyMongo?
client = MongoClient()
client = MongoClient('localhost', 27017)
db = client.taq
collection_str = "mycollection"
db_collection = db[collection_str]
mylist = list(db_collection.find())This issue has been discussed before and I tried the suggestions. One is to change the default batch size. So I tried the following:
cursor = db_collection.find()
cursor.bath_size(10000)
mylist = list(cursor)However, this had no impact. A second suggestion was to check that the C extensions are installed - I have them installed so this is not the issue. The Mongo database is installed on the same machine so it is not a network issue - it works fine from C++ ... querying from Pymongo is the issue.
Since MongoDB is marketed as being able to handle Big Data, surely there is a way to retrieve data quickly via Python? This issue has been raised before but I am yet to find a solution.... has anyone got a suggestion that works? It this case I am retrieving 150k documents, but normally the query would be retrieving 1million so this is going to be a real issue for me.
PS each document is very simple, only containing a datetime field and three integer fields.
--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/M6dxQgvGrbE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
...