I am currently working on a project using PHP
, I have done research and found that microtime()
helps with tracking the time of a query in a MySQL
database..
how do I do the same for MongoDB
, I have a PHP
interface and I have also inserted data into the MongoDB
database using this but how do I show how long the time of the query took to insert into the database.
PHP uses microtime() MongoDB uses ????
1 Answer 1
As per MongoDB BOL Analyze Query Performance usees The cursor.explain("executionStats") and the db.collection.explain("executionStats") methods provide statistics about the performance of a query. This data output can be useful in measuring if and how a query uses an index.
db.collection.explain()
provides information on the execution of other operations, such as db.collection.update().
-
Thank you for the reply, how do I add it to my code so it shows the results when I search the database using the php page ,$m = new MongoDB\Client("mongodb://localhost:27017"); $db=$m->CSV; $mObj=$db->Schools->find()->explain('executionStats'); //foreach($mObj as $oneElement) { //foreach($oneElement['Street'] as $comment) { foreach($mObj as $row) { echo $row['Street']; echo $row['Town']; echo $row['Postcode']; }Robert– Robert2018年01月30日 10:15:46 +00:00Commented Jan 30, 2018 at 10:15