Home > database >  Mongo build data set, writing efficiency was raised
Mongo build data set, writing efficiency was raised

Time:10-29

A single database and insert it into the ten thousand data needs to be three minutes, built a master from an arbitration after only need a minute, who can explain not only the primary database can write? Why write operation will improve the efficiency? This period did not make any read operation,

CodePudding user response:

Seems evaluation should have this effect

CodePudding user response:

Test method is a simple circular insert? It's convenient for provide the method

CodePudding user response:

Right, it is a simple loop insert,

CodePudding user response:

I found the rs test is slower than the single, to more than double the time
 import time 
The from pymongo import MongoClient
Def test (rows, url) :
With MongoClient (url) as the client:
Coll=client. The test. The test
Coll. Drop ()
Starttime=time. Time ()
For I in range (rows) :
Re=coll. Insert (dict (_id=I, time=time. The time (), data=https://bbs.csdn.net/topics/(time, ctime ()) * 1024 * 10))
Print (time. Time () - starttime)

CodePudding user response:

Four or five seconds, I insert ten thousand data is not a simple cycle, there is a complex business judgment... You didn't do is index?
  • Related