php - Mongo faster than MongoClient -
has been disliked after php.net, and it's 3 times faster than the Mongo client!
Try it yourself to run the code given below, which includes 1M documents, it will be completed in ~ 20 seconds, which changes with the Mongo client which is ~ 180 sec < / p>
& lt; Php function mongo_connect ($ db, $) archive) {$ mongo = new mongo ('mongodb: // localhost'); $ Mongo-> $ db- & gt; Return $ Collection; } $ Mongodb = 'notificator1'; $ Mongocollection = 'torque'; $ Collection = Mongo_connect ($ mongodb, $ mongocollection); Echo $ time = Microtim (true) "\ N"; $ I = =; While ($ i & lt; 1000000) {$ row = Array ('title' = & gt; "test # $ i"); $ COLLECTION- & gt; Save ($ line); ++ $ i; } Dumbo microtom (true) - $ time; ? & Gt; Replace mongo_connect:
function mongo_connect ($ db, $ archive) {$ m = New Mongo Client ('mongodb: // localhost: 27017 '); $ Db = $ m- & gt; Select DB ($ db); Return Collection $ New Mongo Collection ($ db, $ Collection); Mongo is fast but this is not a good thing.
Mongo is fast but this is not a good thing.
But the answer to your real question is in the code:
$ mongo = new Mongo ('mongodb: // localhost'); Mongo write the default of concern >> <0> which means that it actually works if the Mongo client . Here's a good post that tells the difference between mongo and mongo client . MongoDB Driver: Now, you can think of why we are changing Mando with MongoClient in Mando. The biggest reason is that the new class will have accepted by default
Comments
Post a Comment