mongo 查询分析 查看索引是有有效
1.执行 db.表名.find(条件).explain() 查看分析结果 类似ORACLE的Sql执行计划
db.MD5Data.find({$and:[ {code:"6512bd43d9caa6e02c990b0a82652dca"} ]}).explain()
看到:
表示索引执行成功
返回数据详情:如下
{ "queryPlanner": { "plannerVersion": NumberInt("1"), "namespace": "MD5.MD5Data", "indexFilterSet": false, "parsedQuery": { "code": { "$eq": "6512bd43d9caa6e02c990b0a82652dca" } }, "queryHash": "184EA866", "planCacheKey": "5C679A65", "winningPlan": { "stage": "FETCH", "inputStage": { "stage": "IXSCAN", "keyPattern": { "code": -1 }, "indexName": "code_-1", "isMultiKey": false, "multiKeyPaths": { "code": [ ] }, "isUnique": false, "isSparse": false, "isPartial": false, "indexVersion": NumberInt("2"), "direction": "forward", "indexBounds": { "code": [ "[\"6512bd43d9caa6e02c990b0a82652dca\", \"6512bd43d9caa6e02c990b0a82652dca\"]" ] } } }, "rejectedPlans": [ ] }, "serverInfo": { "host": "DESKTOP-KFPQ8D5", "port": NumberInt("27017"), "version": "4.2.0", "gitVersion": "a4b751dcf51dd249c5865812b390cfd1c0129c30" }, "ok": 1 }