<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Hafidz Jazuli Luthfi</title>
    <description>The latest articles on Forem by Hafidz Jazuli Luthfi (@bladefidz).</description>
    <link>https://forem.com/bladefidz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F66262%2F0c294da6-262a-4ec0-8063-4675f0bcaeca.jpeg</url>
      <title>Forem: Hafidz Jazuli Luthfi</title>
      <link>https://forem.com/bladefidz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bladefidz"/>
    <language>en</language>
    <item>
      <title>Find The Hot Spot Operation Using Profiling Method On MongoDB</title>
      <dc:creator>Hafidz Jazuli Luthfi</dc:creator>
      <pubDate>Sat, 14 Apr 2018 00:49:22 +0000</pubDate>
      <link>https://forem.com/bladefidz/find-the-hot-spot-operation-using-profiling-method-on-mongodb-36ea</link>
      <guid>https://forem.com/bladefidz/find-the-hot-spot-operation-using-profiling-method-on-mongodb-36ea</guid>
      <description>

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hi, my name Hafidz. I am just regular software developer like almost of you. Currently, I have enrolled &lt;a href="https://university.mongodb.com/courses/M101P/about"&gt;MongoDB for Developers&lt;/a&gt; course from MongoDB university. This course is great and has awesome instructors. While attending the course, I find myself enjoy reading a book &lt;a href="https://www.amazon.com/Parallel-Programming-Techniques-Applications-Workstations/dp/0131405632"&gt;Parallel Programming by Barry Wilkinson and  Michael Allen&lt;/a&gt;. By reading this book, I found more insight about how to evaluate operation performance on MongoDB.&lt;/p&gt;

&lt;p&gt;Here, I like to share what I have already learn from the course and book. It is about how we find The Hot Spot Operation Using Profiling Method On MongoDB.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Gustafson%27s_law"&gt;Gustafson's law&lt;/a&gt; tells us that latency can be used to measure implemented parallel program. Lower the latency we gain, better performance we have. But, find the way to reduce the latency rate is somehow difficult if we have many possible tasks to be executed. One easy way to do that is by optimizing most executed operations. Such operation called as &lt;strong&gt;hot spot&lt;/strong&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Database Profiler on MongoDB
&lt;/h2&gt;

&lt;p&gt;You can find detailed explanation about &lt;strong&gt;Database Profiler&lt;/strong&gt; from &lt;a href="https://docs.mongodb.com/manual/tutorial/manage-the-database-profiler/"&gt;this documentation&lt;/a&gt;. To simplify, we only need to focused on these key points:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Profiling levels&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;0: Off.&lt;/li&gt;
&lt;li&gt;1: On, but selective to given threshold in milliseconds.&lt;/li&gt;
&lt;li&gt;2: On and dumb all execution operations.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Get profiler output&lt;br&gt;
Run this command &lt;code&gt;db.system.profile.find()&lt;/code&gt; to get profiled data. You can found the detailed explanation of profiling output in &lt;a href="https://docs.mongodb.com/manual/reference/database-profiler/"&gt;this documentation&lt;/a&gt;. In order to make this tutorial straight forward, we only focused on some key output:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;op&lt;/strong&gt;: Executed operation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ns&lt;/strong&gt;: Namespace of the operation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;responseLength&lt;/strong&gt;: Document length in bytes resulted from corresponding operation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;millis&lt;/strong&gt;: Time in milliseconds needed by operations to complete the requested documents. Some people called this as &lt;em&gt;latency speed&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Profiling to Find Hot Spot Operations
&lt;/h2&gt;

&lt;p&gt;Suppose we already have some collections and want to do some performance testing. We want to inspect application behavior to find which most executed operations, then save them in the Hot Spot pool and find the best way to optimize them.&lt;/p&gt;

&lt;p&gt;Okay, let get started:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start mongod with profiling option on but be selective to only dump any operations that exceed 100 milliseconds threshold.&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mongod --dbpath /usr/local/share/mongodb --port 27001 --profile 1 --slowms 100
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;ul&gt;
&lt;li&gt;Or alternatively, you can activate profiling in specific database by execute this command:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.setProfilingLevel(1, { slowms: 100 })
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;ul&gt;
&lt;li&gt;Do some operations on the database. MongoDB will create a collection called &lt;code&gt;system.profile&lt;/code&gt; which contains operations profile data.

&lt;/li&gt;
&lt;li&gt;Get top five slowest operations&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.system.profile.find().sort({millis: -1}).limit(10).pretty()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;ul&gt;
&lt;li&gt;Suppose we just execute some query on &lt;strong&gt;school2.students&lt;/strong&gt; collection. So, in the profiling log we got output something like this:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    ...
    "op" : "query",
    "ns" : "school2.students",
    ...
    "millis" : 15820
},
{
    ...
    "op" : "query",
    "ns" : "school2.students",
    ...
    "millis" : 12560
},
{
    ...
    "op" : "query",
    "ns" : "school2.students",
    ...
    "millis" : 11084
},
{
    ...
    "op" : "query",
    "ns" : "school2.students",
    ...
    "millis" : 9493
},
{
    ...
    "op" : "query",
    "ns" : "school2.students",
    ...
    "millis" : 9059
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It's look like that query operation on school2.student2 collection is the Hot Spot operations executed within about one seconds. We may used &lt;code&gt;explain(executionStats)&lt;/code&gt; to the Hot Spot operation in order to analyze execution statistics of the operation. You may find &lt;a href="https://dev.to/bladefidz/how-to-evaluate-query-performance-on-mongodb-4dbm"&gt;this article&lt;/a&gt; would be helpful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Suggestion
&lt;/h2&gt;

&lt;p&gt;Profiling may became easier if we can plot the profiling output into histogram. You may interested &lt;a href="https://late.am/post/2011/09/22/professor-a-mongodb-profile-viewer.html"&gt;this tool&lt;/a&gt; or find your own way to plot the profiling output into histogram.&lt;/p&gt;


</description>
      <category>mongodb</category>
      <category>parallelprogramming</category>
      <category>monitoring</category>
      <category>optimization</category>
    </item>
    <item>
      <title>MongoDB Query Optimization: Covered Query </title>
      <dc:creator>Hafidz Jazuli Luthfi</dc:creator>
      <pubDate>Thu, 12 Apr 2018 13:31:04 +0000</pubDate>
      <link>https://forem.com/bladefidz/mongodb-query-optimization-covered-query--34d2</link>
      <guid>https://forem.com/bladefidz/mongodb-query-optimization-covered-query--34d2</guid>
      <description>

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hi, my name Hafidz. I am just regular software developer like almost of you. Currently, I have enrolled &lt;a href="https://university.mongodb.com/courses/M101P/about"&gt;MongoDB for Developers&lt;/a&gt; course from MongoDB university. This course is great and has awesome instructors. I like to share what I have already learn from this course. It is about how we optimize MongoDB query by implementing covered query.&lt;/p&gt;

&lt;p&gt;This post has correlation with my previous post: &lt;a href="https://dev.to/bladefidz/how-to-evaluate-query-performance-on-mongodb-4dbm"&gt;How to Evaluate Query Performance on MongoDB&lt;/a&gt;. If you want to know more about how to evaluate query performance, than it is good idea to read it before read this post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;If we are not used any indexes on the collection, then MongoDB will performs &lt;code&gt;COLLSCAN&lt;/code&gt;. It's means, if we have &lt;strong&gt;N&lt;/strong&gt; collections, than MongoDB will perform scanning in &lt;strong&gt;N&lt;/strong&gt; times. Your friend who have computer science degree may said to you, "We can do better!". Yes, we can do better by implementing indexing algorithm. MongoDB has been provides lower bound data structure called &lt;a href="https://www.google.com/search?q=B%2B+trees&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;client=firefox-b-ab"&gt;B+ trees&lt;/a&gt; which gives us &lt;strong&gt;Log N&lt;/strong&gt; performance. If you want to know more about the indexing algorithm, then try to read &lt;a href="https://docs.mongodb.com/manual/indexes/index.html"&gt;this documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But, the question is: &lt;em&gt;How we can exploit the indexing algorithm to achieve high performance query?&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Query Optimization using Covered Query
&lt;/h2&gt;

&lt;p&gt;MongoDB has excellent &lt;a href="https://docs.mongodb.com/manual/core/query-optimization/"&gt;documentation&lt;/a&gt; about how to optimizing query. In the case to optimize such query operations that are part of such index or indexes, then we can achieve high performance operation by implementing &lt;strong&gt;Covered Query&lt;/strong&gt;. In other word, we expect that such query operations only examined index field, but not document fields.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Database and Collection
&lt;/h2&gt;

&lt;p&gt;I will be using exactly same collection which used in &lt;a href="https://dev.to/bladefidz/how-to-evaluate-query-performance-on-mongodb-4dbm"&gt;this post&lt;/a&gt;. But in the case you are not have read it or just forget about it, then I will just need to re-explain the same explanation.&lt;/p&gt;

&lt;p&gt;In this easy tutorial, we used a &lt;strong&gt;school&lt;/strong&gt; database and &lt;strong&gt;students&lt;/strong&gt; collection contains 1,000,000 documents. All the documents randomly created from javascript file which you can downloaded from &lt;a href="https://github.com/Bladefidz/mongodb-analytics/blob/master/mongodb%20for%20developers/chapter_4_performance/create_scores2.js"&gt;here&lt;/a&gt;.&lt;br&gt;
Below the description of each key in our document:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;student_id&lt;/strong&gt;: Unique identification of each student.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;scores&lt;/strong&gt;: An array of contains two keys: &lt;em&gt;type&lt;/em&gt; (type of score) and &lt;em&gt;score&lt;/em&gt; (float value).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;class_id&lt;/strong&gt;: Unique identification of each class where student belongs to.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;In this section, we want to know any students defined by &lt;code&gt;student_id&lt;/code&gt; belong to classes &lt;code&gt;5, 15, 30&lt;/code&gt;. So the query is &lt;code&gt;db.students.find({class_id: {$in: [5, 15, 30]}}, {_id: 0, student_id: 1, class_id: 1})&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  First implementation: Without indexing
&lt;/h3&gt;

&lt;p&gt;Run this commands in the shell:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var exp = db.students.explain('executionStats').find({class_id: {$in: [5, 15, 30]}}, {_id: 0, student_id: 1, class_id: 1})
exp
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We got:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
"winningPlan" : {
                        "stage" : "PROJECTION",
                        "transformBy" : {
                                "_id" : 0,
                                "student_id" : 1,
                                "class_id" : 1
                        },
                        "inputStage" : {
                                "stage" : "COLLSCAN",
...
"executionStats" : {
                "executionSuccess" : true,
                "nReturned" : 5977,
                "executionTimeMillis" : 840,
                "totalKeysExamined" : 0,
                "totalDocsExamined" : 1000000,
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Second implementation: With indexing and proper covered query
&lt;/h3&gt;

&lt;p&gt;Run this commands in the shell:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.students.createIndex({class_id: 1, student_id: 1})
var exp = db.students.explain('executionStats').find({class_id: {$in: [5, 15, 30]}}, {_id: 0, student_id: 1, class_id: 1})
exp
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We got:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
"winningPlan" : {
                        "stage" : "PROJECTION",
                        "transformBy" : {
                                "_id" : 0,
                                "student_id" : 1,
                                "class_id" : 1
                        },
                        "inputStage" : {
                                "stage" : "IXSCAN",
...
"executionStats" : {
                "executionSuccess" : true,
                "nReturned" : 5977,
                "executionTimeMillis" : 16,
                "totalKeysExamined" : 5980,
                "totalDocsExamined" : 0,
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;As you can see from explained result, the Covered Query achieved far higher performance than regular non-indexed query which has 2/105 execution time ratio and only need to examined 5980 keys to return 5977 documents. It is pretty good performance gain right? Your computer science friend may glad to look that proof. :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Suggestion
&lt;/h2&gt;

&lt;p&gt;Keep to play around with same collection and try to create multi-key indexes &lt;code&gt;{'scores.score': -1, 'scores.type': 1}&lt;/code&gt;, then execute &lt;code&gt;var exp = db.students.explain('executionStats'); exp.find({'scores.type': 'exam', 'scores.score': {$gte: 90}})&lt;/code&gt;. You may asking why the covered query did not work. Try to read &lt;a href="https://docs.mongodb.com/manual/core/query-optimization/#covered-query"&gt;this documentation&lt;/a&gt; on &lt;strong&gt;Multikey Covering&lt;/strong&gt; section. You will found out why.&lt;/p&gt;


</description>
      <category>mongodb</category>
      <category>queryoptimization</category>
    </item>
    <item>
      <title>How to Evaluate Query Performance on MongoDB</title>
      <dc:creator>Hafidz Jazuli Luthfi</dc:creator>
      <pubDate>Thu, 12 Apr 2018 09:53:18 +0000</pubDate>
      <link>https://forem.com/bladefidz/how-to-evaluate-query-performance-on-mongodb-4dbm</link>
      <guid>https://forem.com/bladefidz/how-to-evaluate-query-performance-on-mongodb-4dbm</guid>
      <description>

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hi, my name Hafidz. I am just regular software developer like almost of you. Currently, I have enrolled &lt;a href="https://university.mongodb.com/courses/M101P/about"&gt;MongoDB for Developers&lt;/a&gt; course from MongoDB university. This course is great and has awesome instructors. I like to share what I have already learn from this course. It is about how we evaluate query performance on MongoDB using &lt;code&gt;explain("executionStats")&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;Evaluating query performance may became complicated if we do not really know which part should be measured. Fortunately, MongoDB provides very handy tool which can be used to evaluate query performance: &lt;code&gt;explain("executionStats")&lt;/code&gt;. This tool provide us some general measurements such as number of examined document and execution time that can be used to do statistical analysis.&lt;/p&gt;

&lt;h2&gt;
  
  
  The explain("executionStats")
&lt;/h2&gt;

&lt;p&gt;You can find detailed explanation of &lt;code&gt;explain("executionStats")&lt;/code&gt; output from &lt;a href="https://docs.mongodb.com/manual/reference/explain-results/#explain.executionStats"&gt;this documentation&lt;/a&gt;. To simplify, we only need to focused on some output keys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;nReturned&lt;/strong&gt;: Number of documents returned by query operation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;executionTimeMillis&lt;/strong&gt;: Total time in milliseconds needed to complete the operation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;totalKeysExamined&lt;/strong&gt;: Returns 0 (zero) if no indexes found in the operations, else returns number of scanned index keys in order to complete the operation. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;totalDocsExamined&lt;/strong&gt;: Total number of examined documents in order to complete the operation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Database and Collection
&lt;/h2&gt;

&lt;p&gt;In this easy tutorial, we used a &lt;strong&gt;school&lt;/strong&gt; database and &lt;strong&gt;students&lt;/strong&gt; collection contains 1,000,000 documents. All the documents randomly created from javascript file which you can downloaded from &lt;a href="https://github.com/Bladefidz/mongodb-analytics/blob/master/mongodb%20for%20developers/chapter_4_performance/create_scores2.js"&gt;here&lt;/a&gt;.&lt;br&gt;
Below the description of each key in our document:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;student_id&lt;/strong&gt;: Unique identification of each student.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;scores&lt;/strong&gt;: An array of contains two keys: &lt;em&gt;type&lt;/em&gt; (type of score) and &lt;em&gt;score&lt;/em&gt; (float value).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;class_id&lt;/strong&gt;: Unique identification of each class where student belongs to.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Evaluation
&lt;/h2&gt;

&lt;p&gt;In this section, we want to know how indexing can improve query performances. In order to simplify the case, we focused only on how to optimizing "Read operation".&lt;/p&gt;

&lt;h3&gt;
  
  
  Initial evaluation
&lt;/h3&gt;

&lt;p&gt;We need to finds any students that have exam score greater than 90. So the query is: &lt;code&gt;db.students.find({'scores.type': 'exam', 'scores.score': {$gte: 90}})&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  First evaluation: Without indexing.
&lt;/h3&gt;

&lt;p&gt;Run this commands in the shell:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var exp = db.students.explain('executionStats');
exp.find({'scores.type': 'exam', 'scores.score': {$gte: 90}})
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We got:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
"executionStats" : {
                "executionSuccess" : true,
                "nReturned" : 343310,
                "executionTimeMillis" : 2843,
                "totalKeysExamined" : 0,
                "totalDocsExamined" : 1000000,
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Second evaluation: With indexing.
&lt;/h3&gt;

&lt;p&gt;Run this commands in the shell:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.students.createIndex({'scores.score': -1, 'scores.type': 1})
var exp = db.students.explain('executionStats');
exp.find({'scores.type': 'exam', 'scores.score': {$gte: 90}})
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We got:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
"executionStats" : {
                "executionSuccess" : true,
                "nReturned" : 343310,
                "executionTimeMillis" : 2284,
                "totalKeysExamined" : 399171,
                "totalDocsExamined" : 343310,
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;From the two evaluations results, we knew that the operation to find any students that have exam score greater than 90 will run faster by using compound index. In this case, collection with indexes &lt;code&gt;{'scores.score': -1, 'scores.type': 1}&lt;/code&gt; performs faster than without indexes (2284 ms vs 2843 ms).&lt;/p&gt;

&lt;h2&gt;
  
  
  Suggestion
&lt;/h2&gt;

&lt;p&gt;Try to run this explain query:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.students.explain('executionStats').find({'scores.score': {$gte: 90}, 'scores.type': 'exam'})
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This query differs from the explain query which used in the evaluation because we flip the find parameters. Maybe you will convinced yourself that this query should be run faster than the query we used in the evaluation tutorial. But in fact, its not. Try to look &lt;code&gt;winningPlan&lt;/code&gt; key on the explain result, you will find out why.&lt;/p&gt;

&lt;p&gt;I have created a &lt;a href="https://github.com/Bladefidz/mongodb-analytics/blob/master/mongodb%20for%20developers/chapter_4_performance/scores2_evaluation.js"&gt;simple javascript code which measures means of "executionTimeMillis"&lt;/a&gt;. Just play around with that code to do statistical analysis, such as measure the standard deviation.&lt;/p&gt;


</description>
      <category>mongodb</category>
      <category>queryevaluation</category>
    </item>
  </channel>
</rss>
