hint

UK[hɪnt] US[hɪnt]

n. Hint; clue, sign; prompt, precaution; trace amount

vt.hint

vi.hint, hint

MongoDB hint() function syntax

Function:Although the MongoDB query optimizer generally works very well, you can also use hints to force MongoDB to use a specified index.

Syntax: >db.users.find({gender:"M"},{user_name:1,_id:0}).hint({gender:1,user_name: 1})

MongoDB hint() function example

>db.users.find({gender:"M"},{user_name:1,_id:0}).hint({gender:1,user_name:1})
可以使用 explain() 函数来分析以上查询:

>db.users.find({gender:"M"},{user_name:1,_id:0}).hint({gender:1,user_name:1}).explain()