Mongostat is functionally similar to the UNIX OR LINUX file system utility vmstat, but provides data regarding mongod or mongos instances.
All the field in the query are part of an index. All field returned in the query are in the same index. Since all the fields present in the query are part of the index, MongoB matches the query conditions and returns the result using the same index without actually looking inside the documents. Since indexes are present in RAM , fetching data from the indexes are much faster as compared to fetching data by scanning documents . Measuring how effective the database and indexing we need analyzing queries. We can analyse using $explain or $hint.
$explain operator provides information on the query, indexes used in the query and other statistics. It is very useful when analyzing how well your indexes are optimized.
The $hint operator forces the query optimizer to use the specified index to run a query. This is particularly useful when you want to test performance of a query with different indexes. Use $hint for testing query performance an indexing strategies. Mongosh provides a helper method hint() for the $hint operator.