Python_mongodb计算增加删除速度
更新:HHH   时间:2023-1-7


 

  1. #! /user/bin/env python 
  2.  
  3.  
  4. from pymongo import Connection 
  5.  
  6. db = Connection().foo 
  7. collection = db.bar 
  8.  
  9. for i in range(10000000): 
  10.     collection.insert({"foo" : "bar""baz" : i, "z" : 10 - i}) 
  11.  
  12. import time 
  13. start = time.time() 
  14.  
  15. collection.remove() 
  16. collection.find_one() 
  17.  
  18. total = time.time() - start 
  19.  
  20. print "%d seconds" % total 

 

返回MongoDB数据库教程...