暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

详解MongoDB慢查询优化

DBA入坑指南 2021-06-15
3013


点击上方蓝字关注我们



一、导语

日常工作中对于业务出现的MongoDB慢查询,如何去优化以便提升用户体验?本篇文章,以公司某业务之前出现的案例带大家一起去探寻慢查询优化之旅,希望能举一反三帮助大家优化好MongoDB慢查询,由于素材涉及到公司的部分数据,所以笔者用随机生成的数据替换掉之前的数据,并且字段名也做了一些修改,但是不影响大家阅读。


二、背景
    
线上有一条查询运行比较长,达到几十秒,当运行次数较多时,导致MongoDB oom killer,发生主备切换,分析慢查导致的查询如下:
    Mon Dec  7 15:43:15.832 I COMMAND [conn72] command test_schema.test_list_info command: find { find: "test_list_info", filter: { xxxCodeXxx: "DB2C8D44F726", pushXtime: { $gte: new Date(1604166860000), $lt: new Date(1604678346860) }, xxxCodeXxxBelong: { $in: [ "2D4B761B7D72", "EC1321FF6AF7", "6F2DE0CDA4DE", "9148E85DD884", "1FB8011CEC78", "36471362D702", "013BDA4B799A", "DFA0AA339CB3", "1FFB9F0C0AF9", "78EFFB2F9D81", "368D14A6A470", "1AD3433D726B" ] }, pushXstatus: { $in: [ 0, 3, 4 ] }, $or: [ { basicXxxResult.basicXxxCode: "6733" } ] }, projection: { xxxId: true, insureArea: true, xxxCodeXxx: true, xxXNameXxx: true, xxxCodeXxxBelong: true, xxXNameXxxBelong: true, businessType: true, nameType: true, sysSource: true, listType: true, xxxUcid: true, licenceXno: true, userid: true, pushXtime: true, pushXstatus: true, noSendReason: true, xxxResult: true, basicXxxResult: true, combeXxxResult: true, quoteXxxGroup: true, $sortKey: { $meta: "sortKey" } }, sort: { pushXtime: -1 }, limit: 10 } planSummary: IXSCAN { xxxCodeXxx: 1.0, pushXtime: 1.0 } keysExamined:268005 docsExamined:268005 fromMultiPlanner:1 replanned:1 cursorExhausted:1 keyUpdates:0 writeConflicts:0 numYields:14482 nreturned:10 reslen:5941 locks:{ Global: { acquireCount: { r: 28966 } }, Database: { acquireCount: { r: 14483 } }, Collection: { acquireCount: { r: 14483 } } } protocol:op_command 64694ms
    我们可以看到keysExamined:268005 docsExamined:268005,索引扫描和回表次数达到惊人的28w+,毫无疑问,这应该是导致慢查的因素。


    三、分析

    查看集合test_list_info信息如下:

      mongos> db.test_list_info.stats()
      {
      "sharded" : false,
      "primary" : "cmgo-hs36uakv_0",
      "ns" : "test_schema.test_list_info",
      "count" : 81478522,
      "size" : 284936444991,
      "avgObjSize" : 3497,
      "storageSize" : 91633369088,
      "capped" : false,
      ……..
      "nindexes" : 15,
      "totalIndexSize" : 10344464384,
      "indexSizes" : {
      "_id_" : 1117822976,
      "xxxId" : 1546698752,
      "userid" : 581955584,
      "sday" : 257048576,
      "idx_company_car" : 1358323712,
      "pushXstatus_1" : 278659072,
      "pushXtime_-1" : 566034432,
      "xxxCodeXxxBelong_-1" : 366555136,
      "licenceXno" : 422629376,
      "businessType_-1" : 260706304,
      "nameType_-1" : 271507456,
      "idx_iarea_ptime" : 710279168,
      "sysUtime_-1" : 1190211584,
      "idx_xxxUcid" : 587911168,
      "idx_ccode_pushXtime" : 828121088
      },
      "ok" : 1
      }

      对于一个文档数量为81478522的大集合,每次查询扫描28w+的索引和文档还是很慢的,所以分析慢查之后,对字段xxxCodeXxx+ xxxCodeXxxBelong+ pushXtime添加联合索引idx_ccode_cbelong,并删除xxxCodeXxx+pushXtime组成的联合索引idx_ccode_pushXtime(冗余索引),我们分析下查询执行计划如下:

        mongos> db.test_list_info.explain('executionStats').find({ xxxCodeXxx: "DB2C8D44F726", pushXtime: { $gte: new Date(1604166860000), $lt: new Date(1604678346860) }, xxxCodeXxxBelong: { $in: [ "2D4B761B7D72", "EC1321FF6AF7", "6F2DE0CDA4DE", "9148E85DD884", "1FB8011CEC78", "36471362D702", "013BDA4B799A", "DFA0AA339CB3", "1FFB9F0C0AF9", "78EFFB2F9D81", "368D14A6A470", "1AD3433D726B" ] }, pushXstatus: { $in: [ 0, 3, 4 ] }, "$or" : [ { "basicXxxResult.basicXxxCode" : { "$in" : [ "ADBA" , "D5EC" , "0C95" , "79D5" , "F7EC" , "6733" , "3D3D" , "7350" , "F31D" , "2DF2" , "DB8B" , "159D"]}} , { "combeXxxResult.specialRuleCode" : { "$in" : [ "28F9" , "928F" , "CC4B" , "3134" , "6860" , "5584" , "f9cd"]}} , { "noSendReason" : { "$in" : [ 1 , 2 , 7 , 8 , 9 , 10 , 11]}} , { "xxxResult" : { "$in" : [ 1 , 2 , 3 , 4 , 5]}}]},{xxxId: true, insureArea: true, xxxCodeXxx: true, xxXNameXxx: true, xxxCodeXxxBelong: true, xxXNameXxxBelong: true, businessType: true, nameType: true, sysSource: true, listType: true, xxxUcid: true, licenceXno: true, userid: true, pushXtime: true, pushXstatus: true, noSendReason: true, xxxResult: true, basicXxxResult: true, combeXxxResult: true, quoteXxxGroup: true, pushXtime: true}).sort({ pushXtime: -1 }).limit(10)

        执行时间从64s+变成了5ms,执行速度大幅度提升,和开发了解业务之后,由于查询$or操作里面的四个字段是不固定的,有可能是一个,也有可能是多个,并且笔者发现$or的四个字段并不是在每个文档都有,这也是之前笔者只对xxxCodeXxx+ xxxCodeXxxBelong+ pushXtime添加联合索引,一个原因是新建的联合索引效率已经比较高,其次$or字段无法利用好索引,并且索引会很大占用过多的磁盘空间,集合索引信息如下:
          mongos> db.test_list_info.getIndexes()
          [
          {
          "v" : 1,
          "key" : {
          "_id" : 1
          },
          "name" : "_id_",
          "ns" : "test_schema.test_list_info"
          },
          {
          "v" : 1,
          "key" : {
          "xxxId" : 1
          },
          "name" : "xxxId",
          "ns" : "test_schema.test_list_info"
          },
          {
          "v" : 1,
          "key" : {
          "userid" : 1
          },
          "name" : "userid",
          "ns" : "test_schema.test_list_info"
          },
          {
          "v" : 1,
          "key" : {
          "sday" : 1
          },
          "name" : "sday",
          "ns" : "test_schema.test_list_info"
          },
          {
          "v" : 1,
          "key" : {
          "xxxCodeXxx" : 1,
          "xxxUcid" : 1
          },
          "name" : "idx_company_car",
          "ns" : "test_schema.test_list_info",
          "background" : true
          },
          {
          "v" : 1,
          "key" : {
          "pushXstatus" : 1
          },
          "name" : "pushXstatus_1",
          "ns" : "test_schema.test_list_info",
          "background" : true
          },
          {
          "v" : 1,
          "key" : {
          "pushXtime" : -1
          },
          "name" : "pushXtime_-1",
          "ns" : "test_schema.test_list_info",
          "background" : true
          },
          {
          "v" : 1,
          "key" : {
          "xxxCodeXxxBelong" : -1
          },
          "name" : "xxxCodeXxxBelong_-1",
          "ns" : "test_schema.test_list_info",
          "background" : true
          },
          {
          "v" : 1,
          "key" : {
          "licenceXno" : 1
          },
          "name" : "licenceXno",
          "ns" : "test_schema.test_list_info"
          },
          {
          "v" : 1,
          "key" : {
          "businessType" : -1
          },
          "name" : "businessType_-1",
          "ns" : "test_schema.test_list_info",
          "background" : true
          },
          {
          "v" : 1,
          "key" : {
          "nameType" : -1
          },
          "name" : "nameType_-1",
          "background" : true,
          "ns" : "test_schema.test_list_info"
          },
          {
          "v" : 1,
          "key" : {
          "insureArea" : 1,
          "pushXtime" : 1
          },
          "name" : "idx_iarea_ptime",
          "background" : true,
          "ns" : "test_schema.test_list_info"
          },
          {
          "v" : 1,
          "key" : {
          "sysUtime" : -1
          },
          "name" : "sysUtime_-1",
          "ns" : "test_schema.test_list_info"
          },
          {
          "v" : 1,
          "key" : {
          "xxxUcid" : 1
          },
          "name" : "idx_xxxUcid",
          "ns" : "test_schema.test_list_info",
          "background" : true
          },
          {
          "v" : 1,
          "key" : {
          "xxxCodeXxx" : 1,
          "xxxCodeXxxBelong" : 1,
          "pushXtime" : 1
          },
          "name" : "idx_ccode_cbelong",
          "ns" : "test_schema.test_list_info",
          "background" : true
          }
          ]
          从上面可以看出,集合居然有15个索引(包括_id索引),这对于一个大集合而言有点过多了。和开发了解一番后,业务需求其实可以换成等值查询,查询如下:
            db.test_list_info.find({ xxxCodeXxx: "DB2C8D44F726", pushXtime: { $gte: new Date(1604166860000), $lt: new Date(1604678346860) }, xxxCodeXxxBelong: { $in: [ "2D4B761B7D72", "EC1321FF6AF7", "6F2DE0CDA4DE", "9148E85DD884", "1FB8011CEC78", "36471362D702", "013BDA4B799A", "DFA0AA339CB3", "1FFB9F0C0AF9", "78EFFB2F9D81", "368D14A6A470", "1AD3433D726B" ] }, pushXstatus: { $in: [ 0, 3, 4 ] }, "basicXxxResult.basicXxxCode" : "6733"},{xxxId: true, insureArea: true, xxxCodeXxx: true, xxXNameXxx: true, xxxCodeXxxBelong: true, xxXNameXxxBelong: true, businessType: true, nameType: true, sysSource: true, listType: true, xxxUcid: true, licenceXno: true, userid: true, pushXtime: true, pushXstatus: true, noSendReason: true, xxxResult: true, basicXxxResult: true, combeXxxResult: true, quoteXxxGroup: true, pushXtime: true}).sort({ pushXtime: -1 }).limit(10)
            笔者觉得这样子的查询,速度应该还行,但是开发测试反馈低概率出现有点慢的查询,于是笔者查看执行计划发现执行时间居然达到几秒,有时甚至达到十几秒。
            由此查询分析变成如下两个查询:
            1、查询一
              db.test_list_info.find({ xxxCodeXxx: "DB2C8D44F726", pushXtime: { $gte: new Date(1604166860000), $lt: new Date(1604678346860) }, xxxCodeXxxBelong: { $in: [ "2D4B761B7D72", "EC1321FF6AF7", "6F2DE0CDA4DE", "9148E85DD884", "1FB8011CEC78", "36471362D702", "013BDA4B799A", "DFA0AA339CB3", "1FFB9F0C0AF9", "78EFFB2F9D81", "368D14A6A470", "1AD3433D726B" ] }, pushXstatus: { $in: [ 0, 3, 4 ] }, "basicXxxResult.basicXxxCode" : "6733"},{xxxId: true, insureArea: true, xxxCodeXxx: true, xxXNameXxx: true, xxxCodeXxxBelong: true, xxXNameXxxBelong: true, businessType: true, nameType: true, sysSource: true, listType: true, xxxUcid: true, licenceXno: true, userid: true, pushXtime: true, pushXstatus: true, noSendReason: true, xxxResult: true, basicXxxResult: true, combeXxxResult: true, quoteXxxGroup: true, pushXtime: true}).sort({ pushXtime: -1 }).limit(10)

              2、查询二

                db.test_list_info.find({ xxxCodeXxx: "DB2C8D44F726", pushXtime: { $gte: new Date(1604166860000), $lt: new Date(1604678346860) }, xxxCodeXxxBelong: { $in: [ "2D4B761B7D72", "EC1321FF6AF7", "6F2DE0CDA4DE", "9148E85DD884", "1FB8011CEC78", "36471362D702", "013BDA4B799A", "DFA0AA339CB3", "1FFB9F0C0AF9", "78EFFB2F9D81", "368D14A6A470", "1AD3433D726B" ] }, pushXstatus: { $in: [ 0, 3, 4 ] }, "basicXxxResult.basicXxxCode" : { "$in" : [ "ADBA" , "D5EC" , "0C95" , "79D5" , "F7EC" , "6733" , "3D3D" , "7350" , "F31D" , "2DF2" , "DB8B" , "159D"]}},{xxxId: true, insureArea: true, xxxCodeXxx: true, xxXNameXxx: true, xxxCodeXxxBelong: true, xxXNameXxxBelong: true, businessType: true, nameType: true, sysSource: true, listType: true, xxxUcid: true, licenceXno: true, userid: true, pushXtime: true, pushXstatus: true, noSendReason: true, xxxResult: true, basicXxxResult: true, combeXxxResult: true, quoteXxxGroup: true, pushXtime: true}).sort({ pushXtime: -1 }).limit(10)
                两个查询除了条件字段basicXxxResult.basicXxxCode不同之外(查询一是等值,查询二是in),其他条件一样,可是两个查询时间的确相差较远,查询一耗时2s+,甚至有时达到10s+,查询二耗时7ms,居然相差如此之大,查看查询执行计划信息(已省略部分信息)如下:

                查询都选择了联合索引idx_ccode_cbelong,对比字段发现部分字段值相差较大,开始继续阅读之前,先带大家解释下相关重要字段信息,说明如下:

                  "executionTimeMillis" :查询计划选择和查询执行所需的总时间(以毫秒为单位)
                  "totalKeysExamined" : 扫描的索引条目数
                  "totalDocsExamined" : 扫描的文档数
                  "works" : 查询执行阶段执行的“工作单元”的数量,查询执行阶段将其工作分为小单元,“工作单位”可能包括检查单个索引键,从集合中提取单个文档,将投影应用于单个文档或执行内部记账
                  "advanced" : 返回的中间结果数量或者返回到父阶段的结果数
                  "needTime" : 未将中间结果返回给其父级的工作循环数。例如,索引扫描阶段可以花费一个工作周期来寻找索引中的新位置而不是返回索引键; 这个工作周期将计入explain.executionStats.executionStages.needTime而不是explain.executionStats.executionStages.advanced
                  "needYield" : 查询阶段暂停处理和让锁导致的存储层请求次数 (此锁机制可防止高优先级请求等待过长时间)
                  "saveState" : 查询阶段暂停处理和保存它当前的执行状态次数,例如准备让出它持有的锁(yield)
                  "restoreState" : 查询阶段恢复一个保存的执行状态次数,例如恢复之前让出的锁(yield),类似协程机制
                  "isEOF" : 执行阶段是否已到达流的结尾,代表查询结束
                  从上面的信息可以看出查询一比查询二需要更多时间,但是最后选择的索引都是索引idx_ccode_cbelong,而且查询都是返回10条数据,但是从执行计划我们也可以看出拒绝的索引为pushXstatus_1、xxxCodeXxxBelong_-1、pushXtime_-1、idx_company_car。MongoDB对于一个可能使用到2个索引及以上的查询会缓存执行计划,我们可以查看下这两个查询的计划缓存信息,操作如下:
                    mongos> db.test_list_info.getPlanCache().listQueryShapes()
                    [
                    {
                    "query" : {
                    "xxxCodeXxx" : "DB2C8D44F726",
                    "xxxUcid" : "b3265911b31648f3ad71a8e14434a7c9"
                    },
                    "sort" : {


                    },
                    "projection" : {
                    "_id" : true,
                    "quoteVersion" : true
                    }
                    },
                    {
                    "query" : {
                    "xxxCodeXxx" : "DB2C8D44F726",
                    "xxxUcid" : "b3265911b31648f3ad71a8e14434a7c9"
                    },
                    "sort" : {


                    },
                    "projection" : {


                    }
                    },
                    {
                    "query" : {
                    "xxxCodeXxx" : "DB2C8D44F726",
                    "pushXtime" : {
                    "$gte" : ISODate("2020-10-31T16:00:00Z"),
                    "$lt" : ISODate("2020-11-06T15:59:00Z")
                    },
                    "xxxCodeXxxBelong" : {
                    "$in" : [
                    "2D4B761B7D72",
                    "EC1321FF6AF7",
                    "6F2DE0CDA4DE",
                    "9148E85DD884",
                    "1FB8011CEC78",
                    "36471362D702",
                    "013BDA4B799A",
                    "DFA0AA339CB3",
                    "1FFB9F0C0AF9",
                    "78EFFB2F9D81",
                    "368D14A6A470",
                    "1AD3433D726B"
                    ]
                    },
                    "pushXstatus" : {
                    "$in" : [
                    0,
                    3,
                    4
                    ]
                    },
                    "basicXxxResult.basicXxxCode" : {
                    "$in" : [
                    "ADBA",
                    "D5EC",
                    "0C95",
                    "79D5",
                    "F7EC",
                    "6733",
                    "3D3D",
                    "7350",
                    "F31D",
                    "2DF2",
                    "DB8B",
                    "159D"
                    ]
                    }
                    },
                    "sort" : {
                    "pushXtime" : -1
                    },
                    "projection" : {
                    "xxxId" : true,
                    "insureArea" : true,
                    "xxxCodeXxx" : true,
                    "xxXNameXxx" : true,
                    "xxxCodeXxxBelong" : true,
                    "xxXNameXxxBelong" : true,
                    "businessType" : true,
                    "nameType" : true,
                    "sysSource" : true,
                    "listType" : true,
                    "xxxUcid" : true,
                    "licenceXno" : true,
                    "userid" : true,
                    "pushXtime" : true,
                    "pushXstatus" : true,
                    "noSendReason" : true,
                    "xxxResult" : true,
                    "basicXxxResult" : true,
                    "combeXxxResult" : true,
                    "quoteXxxGroup" : true
                    }
                    },
                    {
                    "query" : {
                    "xxxCodeXxx" : "DB2C8D44F726",
                    "pushXtime" : {
                    "$gte" : ISODate("2020-10-31T16:00:00Z"),
                    "$lt" : ISODate("2020-11-06T15:59:00Z")
                    },
                    "xxxCodeXxxBelong" : {
                    "$in" : [
                    "2D4B761B7D72",
                    "EC1321FF6AF7",
                    "6F2DE0CDA4DE",
                    "9148E85DD884",
                    "1FB8011CEC78",
                    "36471362D702",
                    "013BDA4B799A",
                    "DFA0AA339CB3",
                    "1FFB9F0C0AF9",
                    "78EFFB2F9D81",
                    "368D14A6A470",
                    "1AD3433D726B"
                    ]
                    },
                    "pushXstatus" : {
                    "$in" : [
                    0,
                    3,
                    4
                    ]
                    },
                    "basicXxxResult.basicXxxCode" : "6733"
                    },
                    "sort" : {
                    "pushXtime" : -1
                    },
                    "projection" : {
                    "xxxId" : true,
                    "insureArea" : true,
                    "xxxCodeXxx" : true,
                    "xxXNameXxx" : true,
                    "xxxCodeXxxBelong" : true,
                    "xxXNameXxxBelong" : true,
                    "businessType" : true,
                    "nameType" : true,
                    "sysSource" : true,
                    "listType" : true,
                    "xxxUcid" : true,
                    "licenceXno" : true,
                    "userid" : true,
                    "pushXtime" : true,
                    "pushXstatus" : true,
                    "noSendReason" : true,
                    "xxxResult" : true,
                    "basicXxxResult" : true,
                    "combeXxxResult" : true,
                    "quoteXxxGroup" : true
                    }
                    }
                    ]

                    我们先看一下查询一缓存的查询计划信息:

                      mongos> db.test_list_info.getPlanCache().getPlansByQuery({
                      ... "query" : {
                      ... "xxxCodeXxx" : "DB2C8D44F726",
                      ... "pushXtime" : {
                      ... "$gte" : ISODate("2020-10-31T16:00:00Z"),
                      ... "$lt" : ISODate("2020-11-06T15:59:00Z")
                      ... },
                      ... "xxxCodeXxxBelong" : {
                      ... "$in" : [
                      ... "2D4B761B7D72",
                      ... "EC1321FF6AF7",
                      ... "6F2DE0CDA4DE",
                      ... "9148E85DD884",
                      ... "1FB8011CEC78",
                      ... "36471362D702",
                      ... "013BDA4B799A",
                      ... "DFA0AA339CB3",
                      ... "1FFB9F0C0AF9",
                      ... "78EFFB2F9D81",
                      ... "368D14A6A470",
                      ... "1AD3433D726B"
                      ... ]
                      ... },
                      ... "pushXstatus" : {
                      ... "$in" : [
                      ... 0,
                      ... 3,
                      ... 4
                      ... ]
                      ... },
                      ... "basicXxxResult.basicXxxCode" : "6733"
                      ... },
                      ... "sort" : {
                      ... "pushXtime" : -1
                      ... },
                      ... "projection" : {
                      ... "xxxId" : true,
                      ... "insureArea" : true,
                      ... "xxxCodeXxx" : true,
                      ... "xxXNameXxx" : true,
                      ... "xxxCodeXxxBelong" : true,
                      ... "xxXNameXxxBelong" : true,
                      ... "businessType" : true,
                      ... "nameType" : true,
                      ... "sysSource" : true,
                      ... "listType" : true,
                      ... "xxxUcid" : true,
                      ... "licenceXno" : true,
                      ... "userid" : true,
                      ... "pushXtime" : true,
                      ... "pushXstatus" : true,
                      ... "noSendReason" : true,
                      ... "xxxResult" : true,
                      ... "basicXxxResult" : true,
                      ... "combeXxxResult" : true,
                      ... "quoteXxxGroup" : true
                      ... }
                      ... })
                      [
                      {
                      "details" : {
                      "solution" : "(index-tagged expression tree: tree=Node\n---Leaf \n---Leaf { xxxCodeXxx: 1.0, xxxCodeXxxBelong: 1.0, pushXtime: 1.0 }, pos: 0\n---Leaf { xxxCodeXxx: 1.0, xxxCodeXxxBelong: 1.0, pushXtime: 1.0 }, pos: 2\n---Leaf { xxxCodeXxx: 1.0, xxxCodeXxxBelong: 1.0, pushXtime: 1.0 }, pos: 2\n---Leaf { xxxCodeXxx: 1.0, xxxCodeXxxBelong: 1.0, pushXtime: 1.0 }, pos: 1\n---Leaf \n)"
                      },
                      "reason" : {
                      "score" : 1.f9cd38351170725,
                      "stats" : {
                      "stage" : "LIMIT",
                      "nReturned" : 10,
                      "executionTimeMillisEstimate" : 769,
                      "works" : 42794,
                      "advanced" : 10,
                      "needTime" : 42784,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 1,
                      "invalidates" : 0,
                      "limitAmount" : 10,
                      "inputStage" : {
                      "stage" : "PROJECTION",
                      "nReturned" : 10,
                      "executionTimeMillisEstimate" : 769,
                      "works" : 42794,
                      "advanced" : 10,
                      "needTime" : 42784,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "transformBy" : {
                      "xxxId" : true,
                      "insureArea" : true,
                      "xxxCodeXxx" : true,
                      "xxXNameXxx" : true,
                      "xxxCodeXxxBelong" : true,
                      "xxXNameXxxBelong" : true,
                      "businessType" : true,
                      "nameType" : true,
                      "sysSource" : true,
                      "listType" : true,
                      "xxxUcid" : true,
                      "licenceXno" : true,
                      "userid" : true,
                      "pushXtime" : true,
                      "pushXstatus" : true,
                      "noSendReason" : true,
                      "xxxResult" : true,
                      "basicXxxResult" : true,
                      "combeXxxResult" : true,
                      "quoteXxxGroup" : true,
                      "$sortKey" : {
                      "$meta" : "sortKey"
                      }
                      },
                      "inputStage" : {
                      "stage" : "SORT_KEY_GENERATOR",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 769,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42784,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "inputStage" : {
                      "stage" : "FETCH",
                      "filter" : {
                      "$and" : [
                      {
                      "basicXxxResult.basicXxxCode" : {
                      "$eq" : "6733"
                      }
                      },
                      {
                      "pushXstatus" : {
                      "$in" : [
                      0,
                      3,
                      4
                      ]
                      }
                      }
                      ]
                      },
                      "nReturned" : 10,
                      "executionTimeMillisEstimate" : 769,
                      "works" : 42793,
                      "advanced" : 10,
                      "needTime" : 42783,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "docsExamined" : 21391,
                      "alreadyHasObj" : 0,
                      "inputStage" : {
                      "stage" : "SORT_MERGE",
                      "nReturned" : 21391,
                      "executionTimeMillisEstimate" : 90,
                      "works" : 42793,
                      "advanced" : 21391,
                      "needTime" : 21402,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "sortPattern" : {
                      "pushXtime" : -1
                      },
                      "dupsTested" : 21400,
                      "dupsDropped" : 0,
                      "inputStages" : [
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 595,
                      "executionTimeMillisEstimate" : 0,
                      "works" : 595,
                      "advanced" : 595,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"1AD3433D726B\", \"1AD3433D726B\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 595,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 2781,
                      "executionTimeMillisEstimate" : 0,
                      "works" : 2781,
                      "advanced" : 2781,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"368D14A6A470\", \"368D14A6A470\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 2781,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 263,
                      "executionTimeMillisEstimate" : 0,
                      "works" : 263,
                      "advanced" : 263,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"78EFFB2F9D81\", \"78EFFB2F9D81\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 263,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 668,
                      "executionTimeMillisEstimate" : 0,
                      "works" : 668,
                      "advanced" : 668,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"1FFB9F0C0AF9\", \"1FFB9F0C0AF9\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 668,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 3500,
                      "executionTimeMillisEstimate" : 10,
                      "works" : 3500,
                      "advanced" : 3500,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"DFA0AA339CB3\", \"DFA0AA339CB3\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 3500,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 2471,
                      "executionTimeMillisEstimate" : 0,
                      "works" : 2471,
                      "advanced" : 2471,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"013BDA4B799A\", \"013BDA4B799A\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 2471,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 1402,
                      "executionTimeMillisEstimate" : 0,
                      "works" : 1402,
                      "advanced" : 1402,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"36471362D702\", \"36471362D702\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 1402,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 2764,
                      "executionTimeMillisEstimate" : 10,
                      "works" : 2764,
                      "advanced" : 2764,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"1FB8011CEC78\", \"1FB8011CEC78\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 2764,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 3761,
                      "executionTimeMillisEstimate" : 0,
                      "works" : 3761,
                      "advanced" : 3761,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"9148E85DD884\", \"9148E85DD884\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 3761,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 0,
                      "works" : 1,
                      "advanced" : 0,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 1,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"EC1321FF6AF7\", \"EC1321FF6AF7\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 0,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 3195,
                      "executionTimeMillisEstimate" : 10,
                      "works" : 3195,
                      "advanced" : 3195,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"6F2DE0CDA4DE\", \"6F2DE0CDA4DE\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 3195,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      },
                      {
                      "stage" : "IXSCAN",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 0,
                      "works" : 1,
                      "advanced" : 0,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 1,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxCodeXxxBelong" : 1,
                      "pushXtime" : 1
                      },
                      "indexName" : "idx_ccode_cbelong",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "backward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxCodeXxxBelong" : [
                      "[\"2D4B761B7D72\", \"2D4B761B7D72\"]"
                      ],
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 0,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      }
                      ]
                      }
                      }
                      }
                      }
                      }
                      },
                      "feedback" : {
                      "nfeedback" : 0,
                      "scores" : [ ]
                      },
                      "filterSet" : false
                      },
                      {
                      "details" : {
                      "solution" : "(index-tagged expression tree: tree=Node\n---Leaf \n---Leaf \n---Leaf { pushXtime: -1.0 }, pos: 0\n---Leaf { pushXtime: -1.0 }, pos: 0\n---Leaf \n---Leaf \n)"
                      },
                      "reason" : {
                      "score" : 1.686004673552367,
                      "stats" : {
                      "stage" : "LIMIT",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 190,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "limitAmount" : 10,
                      "inputStage" : {
                      "stage" : "PROJECTION",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 190,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "transformBy" : {
                      "xxxId" : true,
                      "insureArea" : true,
                      "xxxCodeXxx" : true,
                      "xxXNameXxx" : true,
                      "xxxCodeXxxBelong" : true,
                      "xxXNameXxxBelong" : true,
                      "businessType" : true,
                      "nameType" : true,
                      "sysSource" : true,
                      "listType" : true,
                      "xxxUcid" : true,
                      "licenceXno" : true,
                      "userid" : true,
                      "pushXtime" : true,
                      "pushXstatus" : true,
                      "noSendReason" : true,
                      "xxxResult" : true,
                      "basicXxxResult" : true,
                      "combeXxxResult" : true,
                      "quoteXxxGroup" : true,
                      "$sortKey" : {
                      "$meta" : "sortKey"
                      }
                      },
                      "inputStage" : {
                      "stage" : "SORT_KEY_GENERATOR",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 190,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "inputStage" : {
                      "stage" : "FETCH",
                      "filter" : {
                      "$and" : [
                      {
                      "basicXxxResult.basicXxxCode" : {
                      "$eq" : "6733"
                      }
                      },
                      {
                      "xxxCodeXxx" : {
                      "$eq" : "DB2C8D44F726"
                      }
                      },
                      {
                      "xxxCodeXxxBelong" : {
                      "$in" : [
                      "2D4B761B7D72",
                      "6F2DE0CDA4DE",
                      "EC1321FF6AF7",
                      "9148E85DD884",
                      "1FB8011CEC78",
                      "36471362D702",
                      "013BDA4B799A",
                      "DFA0AA339CB3",
                      "1FFB9F0C0AF9",
                      "78EFFB2F9D81",
                      "368D14A6A470",
                      "1AD3433D726B"
                      ]
                      }
                      },
                      {
                      "pushXstatus" : {
                      "$in" : [
                      0,
                      3,
                      4
                      ]
                      }
                      }
                      ]
                      },
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 180,
                      "works" : 42793,
                      "advanced" : 0,
                      "needTime" : 42793,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "docsExamined" : 42793,
                      "alreadyHasObj" : 0,
                      "inputStage" : {
                      "stage" : "IXSCAN",
                      "nReturned" : 42793,
                      "executionTimeMillisEstimate" : 30,
                      "works" : 42793,
                      "advanced" : 42793,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "pushXtime" : -1
                      },
                      "indexName" : "pushXtime_-1",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "forward",
                      "indexBounds" : {
                      "pushXtime" : [
                      "(new Date(1604678346860), new Date(1604166860000)]"
                      ]
                      },
                      "keysExamined" : 42793,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      }
                      }
                      }
                      }
                      }
                      },
                      "feedback" : {


                      },
                      "filterSet" : false
                      },
                      {
                      "details" : {
                      "solution" : "(index-tagged expression tree: tree=Node\n---Leaf \n---Leaf \n---Leaf \n---Leaf \n---Leaf \n---Leaf { pushXstatus: 1.0 }, pos: 0\n)"
                      },
                      "reason" : {
                      "score" : 1.6860023367761837,
                      "stats" : {
                      "stage" : "PROJECTION",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 320,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "transformBy" : {
                      "xxxId" : true,
                      "insureArea" : true,
                      "xxxCodeXxx" : true,
                      "xxXNameXxx" : true,
                      "xxxCodeXxxBelong" : true,
                      "xxXNameXxxBelong" : true,
                      "businessType" : true,
                      "nameType" : true,
                      "sysSource" : true,
                      "listType" : true,
                      "xxxUcid" : true,
                      "licenceXno" : true,
                      "userid" : true,
                      "pushXtime" : true,
                      "pushXstatus" : true,
                      "noSendReason" : true,
                      "xxxResult" : true,
                      "basicXxxResult" : true,
                      "combeXxxResult" : true,
                      "quoteXxxGroup" : true,
                      "$sortKey" : {
                      "$meta" : "sortKey"
                      }
                      },
                      "inputStage" : {
                      "stage" : "SORT",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 320,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "sortPattern" : {
                      "pushXtime" : -1
                      },
                      "memUsage" : 0,
                      "memLimit" : 33554432,
                      "limitAmount" : 10,
                      "inputStage" : {
                      "stage" : "SORT_KEY_GENERATOR",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 320,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "inputStage" : {
                      "stage" : "FETCH",
                      "filter" : {
                      "$and" : [
                      {
                      "basicXxxResult.basicXxxCode" : {
                      "$eq" : "6733"
                      }
                      },
                      {
                      "xxxCodeXxx" : {
                      "$eq" : "DB2C8D44F726"
                      }
                      },
                      {
                      "pushXtime" : {
                      "$lt" : ISODate("2020-11-06T15:59:00Z")
                      }
                      },
                      {
                      "pushXtime" : {
                      "$gte" : ISODate("2020-10-31T16:00:00Z")
                      }
                      },
                      {
                      "xxxCodeXxxBelong" : {
                      "$in" : [
                      "2D4B761B7D72",
                      "6F2DE0CDA4DE",
                      "EC1321FF6AF7",
                      "9148E85DD884",
                      "1FB8011CEC78",
                      "36471362D702",
                      "013BDA4B799A",
                      "DFA0AA339CB3",
                      "1FFB9F0C0AF9",
                      "78EFFB2F9D81",
                      "368D14A6A470",
                      "1AD3433D726B"
                      ]
                      }
                      }
                      ]
                      },
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 320,
                      "works" : 42793,
                      "advanced" : 0,
                      "needTime" : 42793,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "docsExamined" : 42793,
                      "alreadyHasObj" : 0,
                      "inputStage" : {
                      "stage" : "IXSCAN",
                      "nReturned" : 42793,
                      "executionTimeMillisEstimate" : 20,
                      "works" : 42793,
                      "advanced" : 42793,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "pushXstatus" : 1
                      },
                      "indexName" : "pushXstatus_1",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "forward",
                      "indexBounds" : {
                      "pushXstatus" : [
                      "[0.0, 0.0]",
                      "[3.0, 3.0]",
                      "[4.0, 4.0]"
                      ]
                      },
                      "keysExamined" : 42793,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      }
                      }
                      }
                      }
                      }
                      },
                      "feedback" : {


                      },
                      "filterSet" : false
                      },
                      {
                      "details" : {
                      "solution" : "(index-tagged expression tree: tree=Node\n---Leaf \n---Leaf \n---Leaf \n---Leaf \n---Leaf { xxxCodeXxxBelong: -1.0 }, pos: 0\n---Leaf \n)"
                      },
                      "reason" : {
                      "score" : 1.6860023367761837,
                      "stats" : {
                      "stage" : "PROJECTION",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 1573,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "transformBy" : {
                      "xxxId" : true,
                      "insureArea" : true,
                      "xxxCodeXxx" : true,
                      "xxXNameXxx" : true,
                      "xxxCodeXxxBelong" : true,
                      "xxXNameXxxBelong" : true,
                      "businessType" : true,
                      "nameType" : true,
                      "sysSource" : true,
                      "listType" : true,
                      "xxxUcid" : true,
                      "licenceXno" : true,
                      "userid" : true,
                      "pushXtime" : true,
                      "pushXstatus" : true,
                      "noSendReason" : true,
                      "xxxResult" : true,
                      "basicXxxResult" : true,
                      "combeXxxResult" : true,
                      "quoteXxxGroup" : true,
                      "$sortKey" : {
                      "$meta" : "sortKey"
                      }
                      },
                      "inputStage" : {
                      "stage" : "SORT",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 1573,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "sortPattern" : {
                      "pushXtime" : -1
                      },
                      "memUsage" : 0,
                      "memLimit" : 33554432,
                      "limitAmount" : 10,
                      "inputStage" : {
                      "stage" : "SORT_KEY_GENERATOR",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 1563,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "inputStage" : {
                      "stage" : "FETCH",
                      "filter" : {
                      "$and" : [
                      {
                      "basicXxxResult.basicXxxCode" : {
                      "$eq" : "6733"
                      }
                      },
                      {
                      "xxxCodeXxx" : {
                      "$eq" : "DB2C8D44F726"
                      }
                      },
                      {
                      "pushXtime" : {
                      "$lt" : ISODate("2020-11-06T15:59:00Z")
                      }
                      },
                      {
                      "pushXtime" : {
                      "$gte" : ISODate("2020-10-31T16:00:00Z")
                      }
                      },
                      {
                      "pushXstatus" : {
                      "$in" : [
                      0,
                      3,
                      4
                      ]
                      }
                      }
                      ]
                      },
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 1563,
                      "works" : 42793,
                      "advanced" : 0,
                      "needTime" : 42793,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "docsExamined" : 42793,
                      "alreadyHasObj" : 0,
                      "inputStage" : {
                      "stage" : "IXSCAN",
                      "nReturned" : 42793,
                      "executionTimeMillisEstimate" : 100,
                      "works" : 42793,
                      "advanced" : 42793,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxxBelong" : -1
                      },
                      "indexName" : "xxxCodeXxxBelong_-1",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "forward",
                      "indexBounds" : {
                      "xxxCodeXxxBelong" : [
                      "[\"1AD3433D726B\", \"1AD3433D726B\"]",
                      "[\"368D14A6A470\", \"368D14A6A470\"]",
                      "[\"78EFFB2F9D81\", \"78EFFB2F9D81\"]",
                      "[\"1FFB9F0C0AF9\", \"1FFB9F0C0AF9\"]",
                      "[\"DFA0AA339CB3\", \"DFA0AA339CB3\"]",
                      "[\"013BDA4B799A\", \"013BDA4B799A\"]",
                      "[\"36471362D702\", \"36471362D702\"]",
                      "[\"1FB8011CEC78\", \"1FB8011CEC78\"]",
                      "[\"9148E85DD884\", \"9148E85DD884\"]",
                      "[\"EC1321FF6AF7\", \"EC1321FF6AF7\"]",
                      "[\"6F2DE0CDA4DE\", \"6F2DE0CDA4DE\"]",
                      "[\"2D4B761B7D72\", \"2D4B761B7D72\"]"
                      ]
                      },
                      "keysExamined" : 42793,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      }
                      }
                      }
                      }
                      }
                      },
                      "feedback" : {


                      },
                      "filterSet" : false
                      },
                      {
                      "details" : {
                      "solution" : "(index-tagged expression tree: tree=Node\n---Leaf \n---Leaf { xxxCodeXxx: 1.0, xxxUcid: 1.0 }, pos: 0\n---Leaf \n---Leaf \n---Leaf \n---Leaf \n)"
                      },
                      "reason" : {
                      "score" : 1.6860023367761837,
                      "stats" : {
                      "stage" : "PROJECTION",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 1590,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "transformBy" : {
                      "xxxId" : true,
                      "insureArea" : true,
                      "xxxCodeXxx" : true,
                      "xxXNameXxx" : true,
                      "xxxCodeXxxBelong" : true,
                      "xxXNameXxxBelong" : true,
                      "businessType" : true,
                      "nameType" : true,
                      "sysSource" : true,
                      "listType" : true,
                      "xxxUcid" : true,
                      "licenceXno" : true,
                      "userid" : true,
                      "pushXtime" : true,
                      "pushXstatus" : true,
                      "noSendReason" : true,
                      "xxxResult" : true,
                      "basicXxxResult" : true,
                      "combeXxxResult" : true,
                      "quoteXxxGroup" : true,
                      "$sortKey" : {
                      "$meta" : "sortKey"
                      }
                      },
                      "inputStage" : {
                      "stage" : "SORT",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 1580,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "sortPattern" : {
                      "pushXtime" : -1
                      },
                      "memUsage" : 0,
                      "memLimit" : 33554432,
                      "limitAmount" : 10,
                      "inputStage" : {
                      "stage" : "SORT_KEY_GENERATOR",
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 1580,
                      "works" : 42794,
                      "advanced" : 0,
                      "needTime" : 42794,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "inputStage" : {
                      "stage" : "FETCH",
                      "filter" : {
                      "$and" : [
                      {
                      "basicXxxResult.basicXxxCode" : {
                      "$eq" : "6733"
                      }
                      },
                      {
                      "pushXtime" : {
                      "$lt" : ISODate("2020-11-06T15:59:00Z")
                      }
                      },
                      {
                      "pushXtime" : {
                      "$gte" : ISODate("2020-10-31T16:00:00Z")
                      }
                      },
                      {
                      "xxxCodeXxxBelong" : {
                      "$in" : [
                      "2D4B761B7D72",
                      "6F2DE0CDA4DE",
                      "EC1321FF6AF7",
                      "9148E85DD884",
                      "1FB8011CEC78",
                      "36471362D702",
                      "013BDA4B799A",
                      "DFA0AA339CB3",
                      "1FFB9F0C0AF9",
                      "78EFFB2F9D81",
                      "368D14A6A470",
                      "1AD3433D726B"
                      ]
                      }
                      },
                      {
                      "pushXstatus" : {
                      "$in" : [
                      0,
                      3,
                      4
                      ]
                      }
                      }
                      ]
                      },
                      "nReturned" : 0,
                      "executionTimeMillisEstimate" : 1580,
                      "works" : 42793,
                      "advanced" : 0,
                      "needTime" : 42793,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "docsExamined" : 42793,
                      "alreadyHasObj" : 0,
                      "inputStage" : {
                      "stage" : "IXSCAN",
                      "nReturned" : 42793,
                      "executionTimeMillisEstimate" : 60,
                      "works" : 42793,
                      "advanced" : 42793,
                      "needTime" : 0,
                      "needYield" : 0,
                      "saveState" : 1671,
                      "restoreState" : 1671,
                      "isEOF" : 0,
                      "invalidates" : 0,
                      "keyPattern" : {
                      "xxxCodeXxx" : 1,
                      "xxxUcid" : 1
                      },
                      "indexName" : "idx_company_car",
                      "isMultiKey" : false,
                      "isUnique" : false,
                      "isSparse" : false,
                      "isPartial" : false,
                      "indexVersion" : 1,
                      "direction" : "forward",
                      "indexBounds" : {
                      "xxxCodeXxx" : [
                      "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                      ],
                      "xxxUcid" : [
                      "[MinKey, MaxKey]"
                      ]
                      },
                      "keysExamined" : 42793,
                      "dupsTested" : 0,
                      "dupsDropped" : 0,
                      "seenInvalidated" : 0
                      }
                      }
                      }
                      }
                      }
                      },
                      "feedback" : {


                      },
                      "filterSet" : false
                      }
                      ]

                      里面有每次候选索引的分数,我们可以看出索引idx_ccode_cbelong的分数是最高的,所以优化器会优先选择分数高的索引为最佳索引,我们在看看查询二缓存的查询计划信息,如下:

                        mongos> db.test_list_info.getPlanCache().getPlansByQuery({
                        ... "query" : {
                        ... "xxxCodeXxx" : "DB2C8D44F726",
                        ... "pushXtime" : {
                        ... "$gte" : ISODate("2020-10-31T16:00:00Z"),
                        ... "$lt" : ISODate("2020-11-06T15:59:00Z")
                        ... },
                        ... "xxxCodeXxxBelong" : {
                        ... "$in" : [
                        ... "2D4B761B7D72",
                        ... "EC1321FF6AF7",
                        ... "6F2DE0CDA4DE",
                        ... "9148E85DD884",
                        ... "1FB8011CEC78",
                        ... "36471362D702",
                        ... "013BDA4B799A",
                        ... "DFA0AA339CB3",
                        ... "1FFB9F0C0AF9",
                        ... "78EFFB2F9D81",
                        ... "368D14A6A470",
                        ... "1AD3433D726B"
                        ... ]
                        ... },
                        ... "pushXstatus" : {
                        ... "$in" : [
                        ... 0,
                        ... 3,
                        ... 4
                        ... ]
                        ... },
                        ... "basicXxxResult.basicXxxCode" : {
                        ... "$in" : [
                        ... "ADBA",
                        ... "D5EC",
                        ... "0C95",
                        ... "79D5",
                        ... "F7EC",
                        ... "6733",
                        ... "3D3D",
                        ... "7350",
                        ... "F31D",
                        ... "2DF2",
                        ... "DB8B",
                        ... "159D"
                        ... ]
                        ... }
                        ... },
                        ... "sort" : {
                        ... "pushXtime" : -1
                        ... },
                        ... "projection" : {
                        ... "xxxId" : true,
                        ... "insureArea" : true,
                        ... "xxxCodeXxx" : true,
                        ... "xxXNameXxx" : true,
                        ... "xxxCodeXxxBelong" : true,
                        ... "xxXNameXxxBelong" : true,
                        ... "businessType" : true,
                        ... "nameType" : true,
                        ... "sysSource" : true,
                        ... "listType" : true,
                        ... "xxxUcid" : true,
                        ... "licenceXno" : true,
                        ... "userid" : true,
                        ... "pushXtime" : true,
                        ... "pushXstatus" : true,
                        ... "noSendReason" : true,
                        ... "xxxResult" : true,
                        ... "basicXxxResult" : true,
                        ... "combeXxxResult" : true,
                        ... "quoteXxxGroup" : true
                        ... }
                        ... })
                        [
                        {
                        "details" : {
                        "solution" : "(index-tagged expression tree: tree=Node\n---Leaf { xxxCodeXxx: 1.0, xxxCodeXxxBelong: 1.0, pushXtime: 1.0 }, pos: 0\n---Leaf { xxxCodeXxx: 1.0, xxxCodeXxxBelong: 1.0, pushXtime: 1.0 }, pos: 2\n---Leaf { xxxCodeXxx: 1.0, xxxCodeXxxBelong: 1.0, pushXtime: 1.0 }, pos: 2\n---Leaf \n---Leaf { xxxCodeXxx: 1.0, xxxCodeXxxBelong: 1.0, pushXtime: 1.0 }, pos: 1\n---Leaf \n)"
                        },
                        "reason" : {
                        "score" : 1.1614903225806454,
                        "stats" : {
                        "stage" : "LIMIT",
                        "nReturned" : 10,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 10,
                        "needTime" : 52,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 1,
                        "invalidates" : 0,
                        "limitAmount" : 10,
                        "inputStage" : {
                        "stage" : "PROJECTION",
                        "nReturned" : 10,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 10,
                        "needTime" : 52,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "transformBy" : {
                        "xxxId" : true,
                        "insureArea" : true,
                        "xxxCodeXxx" : true,
                        "xxXNameXxx" : true,
                        "xxxCodeXxxBelong" : true,
                        "xxXNameXxxBelong" : true,
                        "businessType" : true,
                        "nameType" : true,
                        "sysSource" : true,
                        "listType" : true,
                        "xxxUcid" : true,
                        "licenceXno" : true,
                        "userid" : true,
                        "pushXtime" : true,
                        "pushXstatus" : true,
                        "noSendReason" : true,
                        "xxxResult" : true,
                        "basicXxxResult" : true,
                        "combeXxxResult" : true,
                        "quoteXxxGroup" : true,
                        "$sortKey" : {
                        "$meta" : "sortKey"
                        }
                        },
                        "inputStage" : {
                        "stage" : "SORT_KEY_GENERATOR",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 52,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "inputStage" : {
                        "stage" : "FETCH",
                        "filter" : {
                        "$and" : [
                        {
                        "basicXxxResult.basicXxxCode" : {
                        "$in" : [
                        "ADBA",
                        "D5EC",
                        "0C95",
                        "79D5",
                        "F7EC",
                        "6733",
                        "3D3D",
                        "7350",
                        "F31D",
                        "2DF2",
                        "DB8B",
                        "159D"
                        ]
                        }
                        },
                        {
                        "pushXstatus" : {
                        "$in" : [
                        0,
                        3,
                        4
                        ]
                        }
                        }
                        ]
                        },
                        "nReturned" : 10,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 61,
                        "advanced" : 10,
                        "needTime" : 51,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "docsExamined" : 25,
                        "alreadyHasObj" : 0,
                        "inputStage" : {
                        "stage" : "SORT_MERGE",
                        "nReturned" : 25,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 61,
                        "advanced" : 25,
                        "needTime" : 36,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "sortPattern" : {
                        "pushXtime" : -1
                        },
                        "dupsTested" : 34,
                        "dupsDropped" : 0,
                        "inputStages" : [
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 2,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 2,
                        "advanced" : 2,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"1AD3433D726B\", \"1AD3433D726B\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 2,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 2,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 2,
                        "advanced" : 2,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"368D14A6A470\", \"368D14A6A470\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 2,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 1,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 1,
                        "advanced" : 1,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"78EFFB2F9D81\", \"78EFFB2F9D81\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 1,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 1,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 1,
                        "advanced" : 1,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"1FFB9F0C0AF9\", \"1FFB9F0C0AF9\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 1,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 6,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 6,
                        "advanced" : 6,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"DFA0AA339CB3\", \"DFA0AA339CB3\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 6,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 5,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 5,
                        "advanced" : 5,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"013BDA4B799A\", \"013BDA4B799A\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 5,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 2,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 2,
                        "advanced" : 2,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"36471362D702\", \"36471362D702\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 2,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 5,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 5,
                        "advanced" : 5,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"1FB8011CEC78\", \"1FB8011CEC78\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 5,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 4,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 4,
                        "advanced" : 4,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"9148E85DD884\", \"9148E85DD884\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 4,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 1,
                        "advanced" : 0,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 1,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"EC1321FF6AF7\", \"EC1321FF6AF7\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 0,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 6,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 6,
                        "advanced" : 6,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"6F2DE0CDA4DE\", \"6F2DE0CDA4DE\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 6,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        },
                        {
                        "stage" : "IXSCAN",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 1,
                        "advanced" : 0,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 1,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxCodeXxxBelong" : 1,
                        "pushXtime" : 1
                        },
                        "indexName" : "idx_ccode_cbelong",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "backward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxCodeXxxBelong" : [
                        "[\"2D4B761B7D72\", \"2D4B761B7D72\"]"
                        ],
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 0,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        }
                        ]
                        }
                        }
                        }
                        }
                        }
                        },
                        "feedback" : {
                        "nfeedback" : 0,
                        "scores" : [ ]
                        },
                        "filterSet" : false
                        },
                        {
                        "details" : {
                        "solution" : "(index-tagged expression tree: tree=Node\n---Leaf \n---Leaf { pushXtime: -1.0 }, pos: 0\n---Leaf { pushXtime: -1.0 }, pos: 0\n---Leaf \n---Leaf \n---Leaf \n)"
                        },
                        "reason" : {
                        "score" : 1.f9cd,
                        "stats" : {
                        "stage" : "LIMIT",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "limitAmount" : 10,
                        "inputStage" : {
                        "stage" : "PROJECTION",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "transformBy" : {
                        "xxxId" : true,
                        "insureArea" : true,
                        "xxxCodeXxx" : true,
                        "xxXNameXxx" : true,
                        "xxxCodeXxxBelong" : true,
                        "xxXNameXxxBelong" : true,
                        "businessType" : true,
                        "nameType" : true,
                        "sysSource" : true,
                        "listType" : true,
                        "xxxUcid" : true,
                        "licenceXno" : true,
                        "userid" : true,
                        "pushXtime" : true,
                        "pushXstatus" : true,
                        "noSendReason" : true,
                        "xxxResult" : true,
                        "basicXxxResult" : true,
                        "combeXxxResult" : true,
                        "quoteXxxGroup" : true,
                        "$sortKey" : {
                        "$meta" : "sortKey"
                        }
                        },
                        "inputStage" : {
                        "stage" : "SORT_KEY_GENERATOR",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "inputStage" : {
                        "stage" : "FETCH",
                        "filter" : {
                        "$and" : [
                        {
                        "xxxCodeXxx" : {
                        "$eq" : "DB2C8D44F726"
                        }
                        },
                        {
                        "basicXxxResult.basicXxxCode" : {
                        "$in" : [
                        "ADBA",
                        "D5EC",
                        "0C95",
                        "79D5",
                        "F7EC",
                        "6733",
                        "3D3D",
                        "7350",
                        "F31D",
                        "2DF2",
                        "DB8B",
                        "159D"
                        ]
                        }
                        },
                        {
                        "xxxCodeXxxBelong" : {
                        "$in" : [
                        "2D4B761B7D72",
                        "6F2DE0CDA4DE",
                        "EC1321FF6AF7",
                        "9148E85DD884",
                        "1FB8011CEC78",
                        "36471362D702",
                        "013BDA4B799A",
                        "DFA0AA339CB3",
                        "1FFB9F0C0AF9",
                        "78EFFB2F9D81",
                        "368D14A6A470",
                        "1AD3433D726B"
                        ]
                        }
                        },
                        {
                        "pushXstatus" : {
                        "$in" : [
                        0,
                        3,
                        4
                        ]
                        }
                        }
                        ]
                        },
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 61,
                        "advanced" : 0,
                        "needTime" : 61,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "docsExamined" : 61,
                        "alreadyHasObj" : 0,
                        "inputStage" : {
                        "stage" : "IXSCAN",
                        "nReturned" : 61,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 61,
                        "advanced" : 61,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "pushXtime" : -1
                        },
                        "indexName" : "pushXtime_-1",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "forward",
                        "indexBounds" : {
                        "pushXtime" : [
                        "(new Date(1604678346860), new Date(1604166860000)]"
                        ]
                        },
                        "keysExamined" : 61,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        }
                        }
                        }
                        }
                        }
                        },
                        "feedback" : {


                        },
                        "filterSet" : false
                        },
                        {
                        "details" : {
                        "solution" : "(index-tagged expression tree: tree=Node\n---Leaf \n---Leaf \n---Leaf \n---Leaf \n---Leaf \n---Leaf { pushXstatus: 1.0 }, pos: 0\n)"
                        },
                        "reason" : {
                        "score" : 1.5584,
                        "stats" : {
                        "stage" : "PROJECTION",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "transformBy" : {
                        "xxxId" : true,
                        "insureArea" : true,
                        "xxxCodeXxx" : true,
                        "xxXNameXxx" : true,
                        "xxxCodeXxxBelong" : true,
                        "xxXNameXxxBelong" : true,
                        "businessType" : true,
                        "nameType" : true,
                        "sysSource" : true,
                        "listType" : true,
                        "xxxUcid" : true,
                        "licenceXno" : true,
                        "userid" : true,
                        "pushXtime" : true,
                        "pushXstatus" : true,
                        "noSendReason" : true,
                        "xxxResult" : true,
                        "basicXxxResult" : true,
                        "combeXxxResult" : true,
                        "quoteXxxGroup" : true,
                        "$sortKey" : {
                        "$meta" : "sortKey"
                        }
                        },
                        "inputStage" : {
                        "stage" : "SORT",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "sortPattern" : {
                        "pushXtime" : -1
                        },
                        "memUsage" : 0,
                        "memLimit" : 33554432,
                        "limitAmount" : 10,
                        "inputStage" : {
                        "stage" : "SORT_KEY_GENERATOR",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "inputStage" : {
                        "stage" : "FETCH",
                        "filter" : {
                        "$and" : [
                        {
                        "xxxCodeXxx" : {
                        "$eq" : "DB2C8D44F726"
                        }
                        },
                        {
                        "pushXtime" : {
                        "$lt" : ISODate("2020-11-06T15:59:00Z")
                        }
                        },
                        {
                        "pushXtime" : {
                        "$gte" : ISODate("2020-10-31T16:00:00Z")
                        }
                        },
                        {
                        "basicXxxResult.basicXxxCode" : {
                        "$in" : [
                        "ADBA",
                        "D5EC",
                        "0C95",
                        "79D5",
                        "F7EC",
                        "6733",
                        "3D3D",
                        "7350",
                        "F31D",
                        "2DF2",
                        "DB8B",
                        "159D"
                        ]
                        }
                        },
                        {
                        "xxxCodeXxxBelong" : {
                        "$in" : [
                        "2D4B761B7D72",
                        "6F2DE0CDA4DE",
                        "EC1321FF6AF7",
                        "9148E85DD884",
                        "1FB8011CEC78",
                        "36471362D702",
                        "013BDA4B799A",
                        "DFA0AA339CB3",
                        "1FFB9F0C0AF9",
                        "78EFFB2F9D81",
                        "368D14A6A470",
                        "1AD3433D726B"
                        ]
                        }
                        }
                        ]
                        },
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 61,
                        "advanced" : 0,
                        "needTime" : 61,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "docsExamined" : 61,
                        "alreadyHasObj" : 0,
                        "inputStage" : {
                        "stage" : "IXSCAN",
                        "nReturned" : 61,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 61,
                        "advanced" : 61,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "pushXstatus" : 1
                        },
                        "indexName" : "pushXstatus_1",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "forward",
                        "indexBounds" : {
                        "pushXstatus" : [
                        "[0.0, 0.0]",
                        "[3.0, 3.0]",
                        "[4.0, 4.0]"
                        ]
                        },
                        "keysExamined" : 61,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        }
                        }
                        }
                        }
                        }
                        },
                        "feedback" : {


                        },
                        "filterSet" : false
                        },
                        {
                        "details" : {
                        "solution" : "(index-tagged expression tree: tree=Node\n---Leaf \n---Leaf \n---Leaf \n---Leaf \n---Leaf { xxxCodeXxxBelong: -1.0 }, pos: 0\n---Leaf \n)"
                        },
                        "reason" : {
                        "score" : 1.5584,
                        "stats" : {
                        "stage" : "PROJECTION",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "transformBy" : {
                        "xxxId" : true,
                        "insureArea" : true,
                        "xxxCodeXxx" : true,
                        "xxXNameXxx" : true,
                        "xxxCodeXxxBelong" : true,
                        "xxXNameXxxBelong" : true,
                        "businessType" : true,
                        "nameType" : true,
                        "sysSource" : true,
                        "listType" : true,
                        "xxxUcid" : true,
                        "licenceXno" : true,
                        "userid" : true,
                        "pushXtime" : true,
                        "pushXstatus" : true,
                        "noSendReason" : true,
                        "xxxResult" : true,
                        "basicXxxResult" : true,
                        "combeXxxResult" : true,
                        "quoteXxxGroup" : true,
                        "$sortKey" : {
                        "$meta" : "sortKey"
                        }
                        },
                        "inputStage" : {
                        "stage" : "SORT",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "sortPattern" : {
                        "pushXtime" : -1
                        },
                        "memUsage" : 0,
                        "memLimit" : 33554432,
                        "limitAmount" : 10,
                        "inputStage" : {
                        "stage" : "SORT_KEY_GENERATOR",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "inputStage" : {
                        "stage" : "FETCH",
                        "filter" : {
                        "$and" : [
                        {
                        "xxxCodeXxx" : {
                        "$eq" : "DB2C8D44F726"
                        }
                        },
                        {
                        "pushXtime" : {
                        "$lt" : ISODate("2020-11-06T15:59:00Z")
                        }
                        },
                        {
                        "pushXtime" : {
                        "$gte" : ISODate("2020-10-31T16:00:00Z")
                        }
                        },
                        {
                        "basicXxxResult.basicXxxCode" : {
                        "$in" : [
                        "ADBA",
                        "D5EC",
                        "0C95",
                        "79D5",
                        "F7EC",
                        "6733",
                        "3D3D",
                        "7350",
                        "F31D",
                        "2DF2",
                        "DB8B",
                        "159D"
                        ]
                        }
                        },
                        {
                        "pushXstatus" : {
                        "$in" : [
                        0,
                        3,
                        4
                        ]
                        }
                        }
                        ]
                        },
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 61,
                        "advanced" : 0,
                        "needTime" : 61,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "docsExamined" : 61,
                        "alreadyHasObj" : 0,
                        "inputStage" : {
                        "stage" : "IXSCAN",
                        "nReturned" : 61,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 61,
                        "advanced" : 61,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxxBelong" : -1
                        },
                        "indexName" : "xxxCodeXxxBelong_-1",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "forward",
                        "indexBounds" : {
                        "xxxCodeXxxBelong" : [
                        "[\"1AD3433D726B\", \"1AD3433D726B\"]",
                        "[\"368D14A6A470\", \"368D14A6A470\"]",
                        "[\"78EFFB2F9D81\", \"78EFFB2F9D81\"]",
                        "[\"1FFB9F0C0AF9\", \"1FFB9F0C0AF9\"]",
                        "[\"DFA0AA339CB3\", \"DFA0AA339CB3\"]",
                        "[\"013BDA4B799A\", \"013BDA4B799A\"]",
                        "[\"36471362D702\", \"36471362D702\"]",
                        "[\"1FB8011CEC78\", \"1FB8011CEC78\"]",
                        "[\"9148E85DD884\", \"9148E85DD884\"]",
                        "[\"EC1321FF6AF7\", \"EC1321FF6AF7\"]",
                        "[\"6F2DE0CDA4DE\", \"6F2DE0CDA4DE\"]",
                        "[\"2D4B761B7D72\", \"2D4B761B7D72\"]"
                        ]
                        },
                        "keysExamined" : 61,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        }
                        }
                        }
                        }
                        }
                        },
                        "feedback" : {


                        },
                        "filterSet" : false
                        },
                        {
                        "details" : {
                        "solution" : "(index-tagged expression tree: tree=Node\n---Leaf { xxxCodeXxx: 1.0, xxxUcid: 1.0 }, pos: 0\n---Leaf \n---Leaf \n---Leaf \n---Leaf \n---Leaf \n)"
                        },
                        "reason" : {
                        "score" : 1.5584,
                        "stats" : {
                        "stage" : "PROJECTION",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "transformBy" : {
                        "xxxId" : true,
                        "insureArea" : true,
                        "xxxCodeXxx" : true,
                        "xxXNameXxx" : true,
                        "xxxCodeXxxBelong" : true,
                        "xxXNameXxxBelong" : true,
                        "businessType" : true,
                        "nameType" : true,
                        "sysSource" : true,
                        "listType" : true,
                        "xxxUcid" : true,
                        "licenceXno" : true,
                        "userid" : true,
                        "pushXtime" : true,
                        "pushXstatus" : true,
                        "noSendReason" : true,
                        "xxxResult" : true,
                        "basicXxxResult" : true,
                        "combeXxxResult" : true,
                        "quoteXxxGroup" : true,
                        "$sortKey" : {
                        "$meta" : "sortKey"
                        }
                        },
                        "inputStage" : {
                        "stage" : "SORT",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "sortPattern" : {
                        "pushXtime" : -1
                        },
                        "memUsage" : 0,
                        "memLimit" : 33554432,
                        "limitAmount" : 10,
                        "inputStage" : {
                        "stage" : "SORT_KEY_GENERATOR",
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 62,
                        "advanced" : 0,
                        "needTime" : 62,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "inputStage" : {
                        "stage" : "FETCH",
                        "filter" : {
                        "$and" : [
                        {
                        "pushXtime" : {
                        "$lt" : ISODate("2020-11-06T15:59:00Z")
                        }
                        },
                        {
                        "pushXtime" : {
                        "$gte" : ISODate("2020-10-31T16:00:00Z")
                        }
                        },
                        {
                        "basicXxxResult.basicXxxCode" : {
                        "$in" : [
                        "ADBA",
                        "D5EC",
                        "0C95",
                        "79D5",
                        "F7EC",
                        "6733",
                        "3D3D",
                        "7350",
                        "F31D",
                        "2DF2",
                        "DB8B",
                        "159D"
                        ]
                        }
                        },
                        {
                        "xxxCodeXxxBelong" : {
                        "$in" : [
                        "2D4B761B7D72",
                        "6F2DE0CDA4DE",
                        "EC1321FF6AF7",
                        "9148E85DD884",
                        "1FB8011CEC78",
                        "36471362D702",
                        "013BDA4B799A",
                        "DFA0AA339CB3",
                        "1FFB9F0C0AF9",
                        "78EFFB2F9D81",
                        "368D14A6A470",
                        "1AD3433D726B"
                        ]
                        }
                        },
                        {
                        "pushXstatus" : {
                        "$in" : [
                        0,
                        3,
                        4
                        ]
                        }
                        }
                        ]
                        },
                        "nReturned" : 0,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 61,
                        "advanced" : 0,
                        "needTime" : 61,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "docsExamined" : 61,
                        "alreadyHasObj" : 0,
                        "inputStage" : {
                        "stage" : "IXSCAN",
                        "nReturned" : 61,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 61,
                        "advanced" : 61,
                        "needTime" : 0,
                        "needYield" : 0,
                        "saveState" : 2,
                        "restoreState" : 2,
                        "isEOF" : 0,
                        "invalidates" : 0,
                        "keyPattern" : {
                        "xxxCodeXxx" : 1,
                        "xxxUcid" : 1
                        },
                        "indexName" : "idx_company_car",
                        "isMultiKey" : false,
                        "isUnique" : false,
                        "isSparse" : false,
                        "isPartial" : false,
                        "indexVersion" : 1,
                        "direction" : "forward",
                        "indexBounds" : {
                        "xxxCodeXxx" : [
                        "[\"DB2C8D44F726\", \"DB2C8D44F726\"]"
                        ],
                        "xxxUcid" : [
                        "[MinKey, MaxKey]"
                        ]
                        },
                        "keysExamined" : 61,
                        "dupsTested" : 0,
                        "dupsDropped" : 0,
                        "seenInvalidated" : 0
                        }
                        }
                        }
                        }
                        }
                        },
                        "feedback" : {


                        },
                        "filterSet" : false
                        }
                        ]

                        从缓存的执行计划信息可以看出,索引idx_ccode_cbelong分数是最高的,为最优索引。那么两个查询之间到底慢在哪里呢?从上面我们知道查询执行时间包括了查询计划选择时间和实际查询执行的时间,既然查询执行选择是一样的,那么我们可以大胆推测出两个查询之间相差比较大的时间有可能花在了查询计划选择上了,我们该怎么证明自己的猜想呢?很简单,我们对查询使用hint(‘idx_ccode_cbelong’),这样子查询计划直接跳过优化器("rejectedPlans" : [ ]显示为空),直接使用我们强制的索引了,执行查询如下:

                          db.test_list_info.find({ xxxCodeXxx: "DB2C8D44F726", pushXtime: { $gte: new Date(1604166860000), $lt: new Date(1604678346860) }, xxxCodeXxxBelong: { $in: [ "2D4B761B7D72", "EC1321FF6AF7", "6F2DE0CDA4DE", "9148E85DD884", "1FB8011CEC78", "36471362D702", "013BDA4B799A", "DFA0AA339CB3", "1FFB9F0C0AF9", "78EFFB2F9D81", "368D14A6A470", "1AD3433D726B" ] }, pushXstatus: { $in: [ 0, 3, 4 ] }, "basicXxxResult.basicXxxCode" : "6733"},{xxxId: true, insureArea: true, xxxCodeXxx: true, xxXNameXxx: true, xxxCodeXxxBelong: true, xxXNameXxxBelong: true, businessType: true, nameType: true, sysSource: true, listType: true, xxxUcid: true, licenceXno: true, userid: true, pushXtime: true, pushXstatus: true, noSendReason: true, xxxResult: true, basicXxxResult: true, combeXxxResult: true, quoteXxxGroup: true, pushXtime: true}).sort({ pushXtime: -1 }).limit(10).hint('idx_ccode_cbelong')

                          我们可以看出同样的查询,执行变成了199毫秒,相比较之前,至少提升了一个数量级。



                          四、论证

                          从上面我们可以推断出查询计划选择索引是会对执行时间有比较大的影响,为了更好地验证我们的猜想,我们使用查询二进行验证:

                            db.test_list_info.find({ xxxCodeXxx: "DB2C8D44F726", pushXtime: { $gte: new Date(1604166860000), $lt: new Date(1604678346860) }, xxxCodeXxxBelong: { $in: [ "2D4B761B7D72", "EC1321FF6AF7", "6F2DE0CDA4DE", "9148E85DD884", "1FB8011CEC78", "36471362D702", "013BDA4B799A", "DFA0AA339CB3", "1FFB9F0C0AF9", "78EFFB2F9D81", "368D14A6A470", "1AD3433D726B" ] }, pushXstatus: { $in: [ 0, 3, 4 ] }, "basicXxxResult.basicXxxCode" : "6733"},{xxxId: true, insureArea: true, xxxCodeXxx: true, xxXNameXxx: true, xxxCodeXxxBelong: true, xxXNameXxxBelong: true, businessType: true, nameType: true, sysSource: true, listType: true, xxxUcid: true, licenceXno: true, userid: true, pushXtime: true, pushXstatus: true, noSendReason: true, xxxResult: true, basicXxxResult: true, combeXxxResult: true, quoteXxxGroup: true, pushXtime: true}).sort({ pushXtime: -1 }).limit(10)
                            查看执行计划查询耗时(单位毫秒)"executionTimeMillis" : 2419,并且查看各个索引对应的查询执行估算的时间如下表所示

                            索引名

                            估计时间(毫秒)

                            idx_ccode_cbelong

                            250

                            pushXtime_-1

                            200

                            pushXstatus_1

                            360

                            xxxCodeXxxBelong_-1

                            1140

                            idx_company_car

                            500

                            我们对各个索引估算时间求和250 + 200 + 360 + 1140 + 500 = 2450,我们可以看出评估时间和和查询实际执行其实非常接近,下面我们强制查询二走索引idx_ccode_cbelong如下:

                              db.test_list_info.explain('executionStats').find({ xxxCodeXxx: "DB2C8D44F726", pushXtime: { $gte: new Date(1604166860000), $lt: new Date(1604678346860) }, xxxCodeXxxBelong: { $in: [ "2D4B761B7D72", "EC1321FF6AF7", "6F2DE0CDA4DE", "9148E85DD884", "1FB8011CEC78", "36471362D702", "013BDA4B799A", "DFA0AA339CB3", "1FFB9F0C0AF9", "78EFFB2F9D81", "368D14A6A470", "1AD3433D726B" ] }, pushXstatus: { $in: [ 0, 3, 4 ] }, "basicXxxResult.basicXxxCode" : "6733"},{xxxId: true, insureArea: true, xxxCodeXxx: true, xxXNameXxx: true, xxxCodeXxxBelong: true, xxXNameXxxBelong: true, businessType: true, nameType: true, sysSource: true, listType: true, xxxUcid: true, licenceXno: true, userid: true, pushXtime: true, pushXstatus: true, noSendReason: true, xxxResult: true, basicXxxResult: true, combeXxxResult: true, quoteXxxGroup: true, pushXtime: true}).sort({ pushXtime: -1 }).limit(10).hint('idx_ccode_cbelong')

                              从图中我们可以看出executionTimeMillis和executionTimeMillisEstimate时间几乎是相等的,使用hint之后,查询不在经过优化器,直接使用hint的索引执行查询,不在需要去估算各个候选索引选择的时间:250 + 200 + 360 + 1140 + 500 = 2450。另外说明一下,如果我们用clear把计划缓存清空(重启MongoDB也会丢失计划缓存),随后执行hint查询,MongoDB不会将最优的执行计划缓存到cache中,因为压根没经过查询优化器的处理,这点我相信大家也比较容易理解。



                              五、解决方法


                              1、对于此查询使用hint索引idx_ccode_cbelong,不建议使用这种方法,因为导致集合索引和逻辑代码藕合了,后期也更容易出问题,我还是比较倾向于MongoDB查询优化器自己去选。
                              2、此集合索引过多尤其是单列索引,可以根据业务实际查询,删除掉部分不需要的索引。
                              实际解决方案:针对公司业务,笔者实际删除了索引xxxCodeXxxBelong_-1(占据了查询大部分时间),当然在删除前我让开发整理了一份这个集合的查询种类确保删除索引不会对业务产生任何影响,删除索引后线上99%查询执行时间稳定控制在200ms以内,极少数查询也在1.4s以内完成,不再出现执行时间达到好几秒甚至十几秒的情况了,并且笔者让开发把这类查询切到secondary,这样子就不会对primary产生任何影响。



                              六、结论


                              从上面我们可以知道候选索引太多,其实对执行时间是有比较大影响的。在MongoDB开发规范中,我一直建议开发一个集合索引数量控制在10个以内,在满足业务的条件下最好保持在5个左右,宽表尽量不要超过10个,并且优先使用联合索引。索引是一门必须正确实践的艺术,确保没有不必要的索引,并确保存在的索引可以满足绝大多数运行的查询。



                              七、扩展阅读


                              1、索引计划选择的score是怎么计算的?

                              MongoDB版本为3.2.22,代码路径/src/mongo/db/query/plan_ranker.cpp,笔者的三脚猫代码阅读能力只看了对应的部分代码片段并结合注解,做了如下大概的总结,可能讲得不是很清楚望见谅。
                                // 计算每个索引的分数并记录最好的.
                                for (size_t i = 0; i < statTrees.size(); ++i) {
                                if (!candidates[i].failed) {
                                LOGV2_DEBUG(
                                20956,
                                5,
                                "Scoring plan {planIndex}:\n{querySolution}Stats:\n{stats}",
                                "Scoring plan",
                                "planIndex"_attr = i,
                                "querySolution"_attr = redact(candidates[i].solution->toString()),
                                "stats"_attr = redact(
                                Explain::statsToBSON(*statTrees[i]).jsonString(ExtendedRelaxedV2_0_0, true)));
                                LOGV2_DEBUG(20957,
                                2,
                                "Scoring query plan: {planSummary} planHitEOF={planHitEOF}",
                                "Scoring query plan",
                                "planSummary"_attr = Explain::getPlanSummary(candidates[i].root),
                                "planHitEOF"_attr = statTrees[i]->common.isEOF);


                                double score = scoreTree(statTrees[i].get());
                                LOGV2_DEBUG(
                                20958, 5, "Basic plan score: {score}", "Basic plan score", "score"_attr = score);
                                if (statTrees[i]->common.isEOF) {
                                LOGV2_DEBUG(20959,
                                5,
                                "Adding +{eofBonus} EOF bonus to score",
                                "Adding EOF bonus to score",
                                "eofBonus"_attr = eofBonus);
                                score += 1;
                                }


                                scoresAndCandidateindices.push_back(std::make_pair(score, i));
                                } else {
                                failed.push_back(i);
                                LOGV2_DEBUG(20960,
                                2,
                                "Not scoring plan: {planSummary} because the plan failed",
                                "Not scoring a plan because the plan failed",
                                "planSummary"_attr = Explain::getPlanSummary(candidates[i].root));
                                }
                                }


                                double PlanRanker::scoreTree(const PlanStageStats* stats) {
                                所有的分数以1开始
                                double baseScore = 1;


                                “工作单元”的数量,查询执行阶段将其工作分为小单元
                                size_t workUnits = stats->common.works;
                                invariant(workUnits != 0);


                                common.advanced是每个索引扫描的时候是否能在collection拿到符合条件的记录,如果能拿到记录那么common.advanced就加1,workUnits则是总共扫描的次数
                                范围: [0, 1]
                                double productivity =
                                static_cast<double>(stats->common.advanced) static_cast<double>(workUnits);


                                workUnits就是每个索引的扫描次数,那么这里的意思就是取1.0 static_cast(10 * workUnits)和1e-4中最小的值
                                const double epsilon = std::min(1.0 static_cast<double>(10 * workUnits), 1e-4);


                                查询不需执行fetch阶段.
                                double noFetchBonus = epsilon;
                                if (hasStage(STAGE_FETCH, stats)) {
                                noFetchBonus = 0;
                                }


                                解决方案更倾向于没有sort阶段
                                double noSortBonus = epsilon;
                                if (hasStage(STAGE_SORT_DEFAULT, stats) || hasStage(STAGE_SORT_SIMPLE, stats)) {
                                noSortBonus = 0;
                                }


                                索引交叉通常比单字段索引解决方案更慢,需要检查索引键的超集,索引交叉解决方案检查相同数量或更少的文档在这种情况下索引交叉允许我们去检查更少的文档,使用交叉索引会扣分
                                double noIxisectBonus = epsilon;
                                if (hasStage(STAGE_AND_HASH, stats) || hasStage(STAGE_AND_SORTED, stats)) {
                                noIxisectBonus = 0;
                                }


                                double tieBreakers = noFetchBonus + noSortBonus + noIxisectBonus;
                                double score = baseScore + productivity + tieBreakers;


                                if (shouldLog(logv2::LogSeverity::Debug(2))) {
                                StringBuilder sb;
                                sb << "baseScore(" << str::convertDoubleToString(baseScore) << ")"
                                << " + productivity((" << stats->common.advanced << " advanced)/(" << stats->common.works
                                << " works) = " << str::convertDoubleToString(productivity) << ")"
                                << " + tieBreakers(" << str::convertDoubleToString(noFetchBonus) << " noFetchBonus + "
                                << str::convertDoubleToString(noSortBonus) << " noSortBonus + "
                                << str::convertDoubleToString(noIxisectBonus)
                                << " noIxisectBonus = " << str::convertDoubleToString(tieBreakers) << ")";
                                LOGV2_DEBUG(20961,
                                2,
                                "score({score}) = {calculation}",
                                "Plan score calculation",
                                "score"_attr = score,
                                "calculation"_attr = sb.str());
                                }


                                if (internalQueryForceIntersectionPlans.load()) {
                                if (hasStage(STAGE_AND_HASH, stats) || hasStage(STAGE_AND_SORTED, stats)) {
                                强制交叉索引计划
                                score += 3;
                                LOGV2_DEBUG(20962,
                                5,
                                "Score boosted to {newScore} due to intersection forcing",
                                "Score boosted due to intersection forcing",
                                "newScore"_attr = score);
                                }
                                }


                                return score;
                                }
                                从上面代码可以看出IS_EOF状态起决定性作用,如果状态为IS_EOF则加一分,所以一般达到IS_EOF状态的索引都会被选中为最优执行计划,计算一个解决方案(候选索引)的score是由baseScore+productivity+productivity构成的,而tieBreakers,它是由noFetchBonus和noSortBonus和noIxisectBonus总和构成的,通过上述的计算score的公式,MongoDB就可以选择出一个最优的执行计划。


                                2、为什么针对每个候选索引估算时间算入查询总时间?


                                MongoDB会将最优的执行计划缓存到cache中,等待下次同样的查询执行的时候会采用cache中的执行计划,MongoDB优化器计算选择索引时,实际上会touch数据(会实际扫描数据做判断),这个跟MySQL有点不一样,MySQL是通过采集一定数量的page来生成索引统计信息的,但是MySQL和MongoDB都存在由于数据分布不均可能导致优化器选择错误的问题,MySQL 8.0的直方图功能实际在生产上也很鸡肋用处不大。


                                3、为什么MongoDB运维开发规范要限制集合索引个数?

                                一个集合索引太多不仅影响数据插入更新效率占用过多磁盘空间,而且可能会严重影响数据查询速度,所以在MongoDB规范里面,我一直强调每个集合尽量不要超过10个索引,其实我们可以定期去扫描MongoDB是否存在冗余索引,当然还要结合具体业务做具体分析,并没有硬性要求,另外MongoDB schemaless是MongoDB的优势同时也是它的劣势,很难像审核MySQL那样去审核MongoDB,对于开发者能力而言,使用MongoDB的要求其实也比使用MySQL要高,所以我们要用好MongoDB优点的同时尽量避开它的缺点。


                                4、MongoDB适合用在公司的核心业务系统上面吗?

                                这个问题很明显是YES,笔者之前所在公司把MongoDB用在最核心的系统上面,MongoDB天然支持分布式的特点可以解决很多性能和扩展问题,但是DBA对MongoDB必须要有一定的把控能力,比如核心核心系统用了分布式MongoDB那么要对所有集合分片防止出现数据和性能倾斜,可以自定义用户角色控制用户权限,核心数据要使用写关注等,另外针对MongoDB定期对开发做一下相关培训。


                                八、参考资料


                                1、explain结果
                                https://docs.mongodb.com/manual/reference/explain-results/
                                2、计划缓存
                                https://docs.mongodb.com/manual/reference/method/PlanCache.list/#PlanCache.list










                                扫描二维码获取

                                更多知识

                                DBA入坑指南








                                点个在看 你最好看




                                文章转载自DBA入坑指南,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                                评论