gpt4 book ai didi

MongoDB后台索引大小

转载 作者:可可西里 更新时间:2023-11-01 09:12:30 25 4
gpt4 key购买 nike

我正在创建一个索引({ a : 1, b : -1 }),一次在前台,其他在后台进行。检查总索引大小。前台:82536720背景:154927024

有人能告诉我为什么会有这么大的尺寸差异吗?

Mongo > db.testing.ensureIndex({a:1,b:-1})
Mongo > db.testing.stats()
{
"ns" : "test.testing",
"count" : 2402158,
"size" : 86479836,
"avgObjSize" : 36.00089419596879,
"totalIndexSize" : 160486704,
"indexSizes" : {
"_id_" : 77949984,
"a_1_b_-1" : 82536720
},
}
Mongo > db.testing.dropIndexes()
Mongo > db.testing.ensureIndex({a:1,b:-1},{background : true})
Mongo > db.testing.stats()
{
"count" : 2402158,
"size" : 86479836,
"avgObjSize" : 36.00089419596879,
"totalIndexSize" : 232877008,
"indexSizes" : {
"_id_" : 77949984,
"a_1_b_-1" : 154927024
},
}

最佳答案

MongoDB documentation

Background index construction allows read and write operations to continue while building the index; however, these index builds take longer to complete and result in a larger index.

所以,不足为奇。基本上,mongo 使用与前台索引不同的机制来构建后台索引,这导致最终索引更大。

关于MongoDB后台索引大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16409880/

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