MongoDB hint() function


  Translation results:

hint

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

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

vt.hint

vi.hint, hint

MongoDB hint() functionsyntax

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() functionexample

>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()

Popular Recommendations

Home

Videos

Q&A