pymongo 2.6 vs 3.2

From: Valentin Kuznetsov <vkuznet@xxxxxxxxx>
To: mongodb-user <mongodb-user@xxxxxxxxxxxxxxxx>
Date: Fri, 13 May 2016 11:34:06 -0700 (PDT)
Why ads?
Hi,
I'm trying to understand slowness of pymongo 3.2 vs pymongo 2.6 before 
making an upgrade. Can someone provide more insight on this issue.
I run the same script using both drivers and the code is below. What I 
found is that on average pymogno 3.2 is slower by factor of 10 vs pymongo 
2.6 on find/counting operations, e.g. some numbers I got (they vary time to 
time, that's why I said on average I see factor of 10):

pymongo 2.6.3, ndocs 9999, time 0.00221014022827
pymongo 3.2.2, ndocs 9999, time 0.149842977524

and here is the code applied to both cases:

#!/usr/bin/env python
import itertools
import time
import pprint
from pymongo import MongoClient, DESCENDING, ASCENDING, version
from pymongo.errors import DuplicateKeyError

uri = 'mongodb://localhost:8230'
client = MongoClient(uri)
coll = client['test']['db']
coll.drop()
coll.create_index([('ts',DESCENDING)])
coll.create_index([('ts',ASCENDING)])

gen = ({'ts':idx} for idx in range(1000000))
try:
    ndocs = coll.insert_many(gen)
except:
    while True:
        try:
            ndocs = coll.insert(itertools.islice(gen, 1000))
            if  not ndocs:
                break
        except:
            break

time0 = time.time()
spec = {"ts":{"$lt":9999}}
# pprint.pprint(coll.find(spec).explain())
ndocs = coll.find(spec).count()
print("pymongo %s, ndocs %s, time %s" % (version, ndocs, time.time()-time0))

Thanks,
Valentin.

-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
--- 
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+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/90046b43-5c3f-44ee-85ad-2030bc6bcae1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Why ads?