gpt4 book ai didi

performance - 缓慢的 MongoDB 查询 : can you explain why?

转载 作者:可可西里 更新时间:2023-11-01 09:32:23 26 4
gpt4 key购买 nike

我有一个 MongoDB 查询,运行时间过长,但它:

  • 仅扫描 6 个对象
  • 点击索引
  • 持续花费约 1500 毫秒(没有分页或其他占用)
  • mongostat 中的索引 miss% 为 0

它出现在分析器中(没有 explain()),我不明白为什么这么慢。有什么想法吗?

gimmebar:PRIMARY> db.assets.find({ owner: "123", avatar: false, private: false }).sort({date: -1}).explain()
{
"cursor" : "BtreeCursor owner_1_avatar_1_date_-1",
"nscanned" : 6,
"nscannedObjects" : 6,
"n" : 6,
"millis" : 1567,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : {
"owner" : [
[
"123",
"123"
]
],
"avatar" : [
[
false,
false
]
],
"date" : [
[
{
"$maxElement" : 1
},
{
"$minElement" : 1
}
]
]
}
}

最佳答案

缺少 private key 的索引?

BtreeCursor owner_1_avatar_1_date_-1 vs .find({ owner: "123", avatar: false, private: false }).sort({date: -1})

关于performance - 缓慢的 MongoDB 查询 : can you explain why?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8720535/

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