I want to compare query execution time between collection that using index and not using index.
You can use the explain() statements for this; they’re covered in M201 among others.
Hi,
@Tess_Sluijter is absolutely right, please take a look at:
https://docs.mongodb.com/manual/reference/method/cursor.explain/
https://docs.mongodb.com/manual/reference/explain-results/
José Carlos
Thanks. Will take a look at it
Q1. Say you created a limited data-set to test the various pipeline (say 10 records), would execution time, be able to give an honest reflection of the execution of the pipeline?
Q2. I used the atlas sandbox from M001 to do some tests, however I seem to hit a problem executing.
db.question5data.explain(“executionStats”).aggregate() or
db.question5data.explain(true).aggregate()
Which hit me with the error (see below), the same command without the
2018-12-18T16:47:07.565+0000 E QUERY [thread1] [src/mongo/shell/utils.js:25:13] Error: explain failed: {
“ok” : 0,
“errmsg” : "not authorized on finalExam to execute command { aggregate: “question5data”, pipeline: [[{$match … blah blah blah
Anyway, if there a setting I need to change on my Atlas sand box to allow this command to run. I appreciate it is a little bit late now, but it would be useful in the next course.