Analyzing queries is the major aspect to measure how effective the database and indexing design is. We will explain you about the frequently used $explain and $hint queries.
$explain operator will provide information on the query, indexes used in a query and other statistics. It is very useful while analyzing how well your indexes are optimized.
In the last chapter, we created an index for the users collection on fields gender and user_name using the following query
We are using $explain on the following query
Above explain() query will return below analyzed result
Let’s have a look at the fields in this result set
$hint operator will force the query optimizer to use the specified index to run a query. This is mainly useful when you wish to test the performance of a query with various indexes. For example, below query will specify the index on fields gender and user_name to be used for this query
To analyze the above query using $explain
MongoDB Related Interview Questions
|Python Interview Questions||C & Data Structures Interview Questions|
|Hadoop Interview Questions||Node.js Interview Questions|
|Scala Interview Questions||Socket Programming Interview Questions|
|HBase Interview Questions||Solaris Administrator Interview Questions|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.