db.people.find( { name: "John Doe", zipcode: { $gt: "63000" } } ).hint( { zipcode: 1 } ).explain("executionStats") 

Or, append hint() method to db.collection.explain().find() : 

db.people.explain("executionStats").find( { name: "John Doe", zipcode: { $gt: "63000" } } ).hint( { zipcode: 1 } ) 

Specify the $natural operator to the hint() method to prevent MongoDB from using any index: 

db.people.find( { name: "John Doe", zipcode: { $gt: "63000" } } ).hint( { $natural: 1 } ) 

Instance Index Use Reporting MongoDB provides a number of metrics of index use and operation that you may want to consider when analyzing index use for your database: 

• In the output of serverStatus : 

• In the output of collStats : 

• In the output of dbStats : 

## 8.3.3 Geospatial Index Tutorials 

Instructions for creating and querying 2d , 2dsphere , and haystack indexes. 

– scanned 

– scanAndOrder 

– totalIndexSize 

– indexSizes 

– dbStats.indexes 

– dbStats.indexSize 

Create a 2dsphere Index (page 530) A 2dsphere index supports data stored as both GeoJSON objects and as legacy coordinate pairs. 

Query a 2dsphere Index (page 531) Search for locations within, near, or intersected by a GeoJSON shape, or within a circle as defined by coordinate points on a sphere. 

Create a 2d Index (page 533) Create a 2d index to support queries on data stored as legacy coordinate pairs. 

Query a 2d Index (page 534) Search for locations using legacy coordinate pairs. 

Create a Haystack Index (page 536) A haystack index is optimized to return results over small areas. For queries that use spherical geometry, a 2dsphere index is a better option. 

Query a Haystack Index (page 536) Search based on location and non-location data within a small area. 

Calculate Distance Using Spherical Geometry (page 537) Convert distances to radians and back again. 

