the efficiency between pymongo and mongoengine
Hey, Ross Lawley, I'm using mongoengine and writing some code in my repo to compare the efficiency between pymongo and mongoengine in a million level documents. And It seems that pymongo has a better efficiency. I am sure that you also have test the efficiency between them. When I want to bulk update, the pymongo is so slow. I don't know whether there is some problems about my code. By the way, do you ever have any code to test the efficiency between two, can you share? Thanks. The following is my code to test time of updating using pymongo
start_time = time.time()
56 print 'the start time is %f' %start_time 57 results = conn.repost_detail.find( 58 { 59 'created_at':{ 60 '$lt': datetime( 61 TIME_SIZE_DICT[size][0], 62 TIME_SIZE_DICT[size][1], 63 TIME_SIZE_DICT[size][2], 64 TIME_SIZE_DICT[size][3], 65 TIME_SIZE_DICT[size][4], 66 ) 67 } 68 69 } 70 ) 71 for result in results: 72 conn.repost_detail.update( 73 result, 74 {'$set': {'city': '200'}}, 75 safe=safe_mode 76 ) 77 end_time = time.time() 78 print 'the endtime is %f' %end_time 79 return end_time - start_time
Hi Jack,
Thanks for your notes, performance is on the roadmap for the next point release (0.7). Currently it can be much slower, it will depend on your document structure and the fields you use. I have a benchmark script I have used, I may publish it with some comparisons with the 0.7 release.
I'm currently, looking into a couple of avenues to improve efficiency and will pick the simplest and most flexible approach, I'll also ensure we can handle upgrading current code bases.
Ross
On Saturday, April 28, 2012, jack xu wrote:
Hey, Ross Lawley, I'm using mongoengine and writing some code in my repo to compare the efficiency between pymongo and mongoengine in a million level documents. And It seems that pymongo has a better efficiency. I am sure that you also have test the efficiency between them. When I want to bulk update, the pymongo is so slow. I don't know whether there is some problems about my code. By the way, do you ever have any code to test the efficiency between two, can you share? Thanks. The following is my code to test time of updating using pymongo
start_time = time.time()56 print 'the start time is %f' %start_time 57 results = conn.repost_detail.find( 58 { 59 'created_at':{ 60 '$lt': datetime( 61 TIME_SIZE_DICT[size][0], 62 TIME_SIZE_DICT[size][1], 63 TIME_SIZE_DICT[size][2], 64 TIME_SIZE_DICT[size][3], 65 TIME_SIZE_DICT[size][4], 66 ) 67 } 68 69 } 70 ) 71 for result in results: 72 conn.repost_detail.update( 73 result, 74 {'$set': {'city': '200'}}, 75 safe=safe_mode 76 ) 77 end_time = time.time() 78 print 'the endtime is %f' %end_time 79 return end_time - start_time
Reply to this email directly or view it on GitHub: https://github.com/hmarr/mongoengine/issues/490