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

Md Haidar Ali Khan
6,5339 gold badges40 silver badges62 bronze badges
asked Jan 24, 2018 at 15:07

1 Answer 1

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().

answered Jan 30, 2018 at 10:07
1
  • 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']; } Commented Jan 30, 2018 at 10:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.