0

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 ????

bumped to the homepage by Community yesterday

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

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 Jan 30 '18 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.