即使索引

时间:2017-07-10 18:29:35

标签: mongodb

我已经运行了几周的mongo测试服务器,一切都很顺利。我有一个查询来获取已删除文件的计数,它在1.4秒文档(44 gb数据)的1秒范围内运行。今天,所有突然相同的查询都需要一段时间。当在查询查询上运行解释时,它显示它正在使用到位的索引,但它仍然需要很长时间。奇怪的是,这不是唯一一个看起来这样做的查询。如果我运行一个返回1项的查询,它几乎是瞬间完成的。当它返回一组文件时,它需要永远(多分钟)。下面是Mongo shell的查询和解释输出。我已经删除了被拒绝的节省空间的计划,但如果需要可以把它放回去。我是mongo的新手所以非常感谢任何帮助。我有另一个查询,我一直在等待24分钟,这只是在EventID字段上搜索,这是一个索引字段。

 db.EventEntries.find({IsDelete:true, TimeCreated:{$gte:ISODate('2017-06-30')}}).explain('executionStats')
{
    "queryPlanner" : {
            "plannerVersion" : 1,
            "namespace" : "Events.EventEntries",
            "indexFilterSet" : false,
            "parsedQuery" : {
                    "$and" : [
                            {
                                    "IsDelete" : {
                                            "$eq" : true
                                    }
                            },
                            {
                                    "TimeCreated" : {
                                            "$gte" : ISODate("2017-06-30T00:00:00Z")
                                    }
                            }
                    ]
            },
            "winningPlan" : {
                    "stage" : "FETCH",
                    "inputStage" : {
                            "stage" : "IXSCAN",
                            "keyPattern" : {
                                    "IsDelete" : 1,
                                    "TimeCreated" : 1
                            },
                            "indexName" : "IsDelete_1_TimeCreated_1",
                            "isMultiKey" : true,
                            "multiKeyPaths" : {
                                    "IsDelete" : [ ],
                                    "TimeCreated" : [
                                            "TimeCreated"
                                    ]
                            },
                            "isUnique" : false,
                            "isSparse" : false,
                            "isPartial" : false,
                            "indexVersion" : 2,
                            "direction" : "forward",
                            "indexBounds" : {
                                    "IsDelete" : [
                                            "[true, true]"
                                    ],
                                    "TimeCreated" : [
                                            "[new Date(1498780800000), new Date(9223372036854775807)]"
                                    ]
                            }
                    }
            },

    },
    "executionStats" : {
            "executionSuccess" : true,
            "nReturned" : 138570,
            "executionTimeMillis" : 177933,
            "totalKeysExamined" : 138570,
            "totalDocsExamined" : 138570,
            "executionStages" : {
                    "stage" : "FETCH",
                    "nReturned" : 138570,
                    "executionTimeMillisEstimate" : 177834,
                    "works" : 138571,
                    "advanced" : 138570,
                    "needTime" : 0,
                    "needYield" : 0,
                    "saveState" : 8887,
                    "restoreState" : 8887,
                    "isEOF" : 1,
                    "invalidates" : 0,
                    "docsExamined" : 138570,
                    "alreadyHasObj" : 0,
                    "inputStage" : {
                            "stage" : "IXSCAN",
                            "nReturned" : 138570,
                            "executionTimeMillisEstimate" : 561,
                            "works" : 138571,
                            "advanced" : 138570,
                            "needTime" : 0,
                            "needYield" : 0,
                            "saveState" : 8887,
                            "restoreState" : 8887,
                            "isEOF" : 1,
                            "invalidates" : 0,
                            "keyPattern" : {
                                    "IsDelete" : 1,
                                    "TimeCreated" : 1
                            },
                            "indexName" : "IsDelete_1_TimeCreated_1",
                            "isMultiKey" : true,
                            "multiKeyPaths" : {
                                    "IsDelete" : [ ],
                                    "TimeCreated" : [
                                            "TimeCreated"
                                    ]
                            },
                            "isUnique" : false,
                            "isSparse" : false,
                            "isPartial" : false,
                            "indexVersion" : 2,
                            "direction" : "forward",
                            "indexBounds" : {
                                    "IsDelete" : [
                                            "[true, true]"
                                    ],
                                    "TimeCreated" : [
                                            "[new Date(1498780800000), new Date(9223372036854775807)]"
                                    ]
                            },
                            "keysExamined" : 138570,
                            "seeks" : 1,
                            "dupsTested" : 138570,
                            "dupsDropped" : 0,
                            "seenInvalidated" : 0
                    }
            }
    },
    "serverInfo" : {
            "host" : "",
            "port" : ,
            "version" : "3.4.4",
            "gitVersion" : "888390515874a9debd1b6c5d36559ca86b44babd"
    },
    "ok" : 1

}

0 个答案:

没有答案