小编Mat*_*ich的帖子

为什么字段上的索引是不同的大小,具体取决于MongoDB中的索引是升序还是降序

我的集合中的"已创建"字段有两个单独的索引.一个索引按升序排序,另一个索引按降序排序.按降序排序的索引大于按升序排序的索引.创建的字段包含Javascript Date对象.什么会导致这个?

"indexSizes" : {
    "_id_" : 212862160,
    "created_1" : 136424736,
    "created_-1" : 252376768
},
Run Code Online (Sandbox Code Playgroud)

以下是collection.getIndexes()的详细信息.唯一的区别是在后台创建了降序索引.

{
    "v" : 1,
    "key" : {
        "created" : 1
    },
    "name" : "created_1",
    "ns" : "Production.accounts"
},
{
    "v" : 1,
    "key" : {
        "created" : -1
    },
    "name" : "created_-1",
    "ns" : "Production.accounts",
    "background" : true
}
Run Code Online (Sandbox Code Playgroud)

sorting indexing mongodb mongodb-query

5
推荐指数
1
解决办法
76
查看次数

标签 统计

indexing ×1

mongodb ×1

mongodb-query ×1

sorting ×1