MongoDB 版本 3.0.6
我正在执行多个查询,发现它们使用了错误的索引。我想 mongo 有 USE INDEX()
或 hint()
,但我在文档中找不到它。我正在使用java。其中一个查询如下所示:
FindIterable<Document> iterable = db.getCollection(collectionName).find(
new Document()
.append("timestamp", new Document()
.append("$gte", startTime)
.append("$lte", endTime))
);
...我希望查询使用我创建的名为 timestamp
的索引。
最佳答案
你可以使用mongo的$hint。 更多详情请参阅
关于java - MongoDB:java中的提示索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36937749/