Reputation: 228
I work on a benchmark between pymongo and rethinkdb, to compare the time took for insertions.
However this is what I found :
for one-by-one insertions.
def chronometre_rethink_insert_one(data, nblines):
avant = time()
for i in data[:nblines]:
r.table('test_table').insert(dict(zip(names, i))).run()
return time()-avant
def chronometre_mongo_insert_one(data, nblines):
avant = time()
for i in data[:nblines]:
db.test_table.insert_one(dict(zip(names, i)))
return time()-avant
I think that the fact that takes mongo is nearly constant is weird. So I wonder maybe pymongo doesn't insert the data whenever I insert it, but rethinkdb yes, as I call run() on all operations ?
If so, how should I have comparable results ?
Upvotes: 3
Views: 3332
Reputation: 228
It's turn out that I can manage it doing :
client = MongoClient(port=27017, fsync=True)
(adding the fsync), as it "Force the database to fsync all files before returning" (https://api.mongodb.com/python/2.0/api/pymongo/connection.html).
This done, I have result that makes more sense:
Upvotes: 0
Reputation: 6849
Is PyMongo asyncronous?
According to their documentation (https://pymongo.readthedocs.io/en/stable/faq.html), PyMongo fully supports Gevent: So yes, if implemented correctly, PyMongo is able to use an asynchronous framework like Gevent.
Details on how what Gevent is, or how to implement it in your example code:
Upvotes: 0