gpt4 book ai didi

java - MongoDB:java中的提示索引

转载 作者:太空宇宙 更新时间:2023-11-04 12:39:46 24 4
gpt4 key购买 nike

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。更多详情请参阅

https://docs.mongodb.org/v3.0/reference/operator/meta/hint/

关于java - MongoDB:java中的提示索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36937749/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com