- Reference >
- Operators >
- Query Modifiers >
- $hint
$hint¶
-
$hint¶ The
$hintoperator forces the query optimizer to use a specific index to fulfill the query. Specify the index either by the index name or by document.Use
$hintfor testing query performance and indexing strategies. Themongoshell provides a helper methodhint()for the$hintoperator.Consider the following operation:
This operation returns all documents in the collection named
usersusing the index on theagefield.You can also specify a hint using either of the following forms: