pymongodb-explain

    '''nReturned和totalDocsExamined最好接近,查询效率更优'''
    qp = {'executionStats': {'allPlansExecution': [],
                             'executionStages': {'advanced': 16591,
                                                 'executionTimeMillisEstimate': 4,
                                                 'inputStage': {'advanced': 16591,
                                                                'alreadyHasObj': 0,
                                                                'docsExamined': 24886,  # 指定在查询执行阶段扫描的文档数。
                                                                'executionTimeMillisEstimate': 3,
                                                                'filter': {'$or': [{'room_num': {'$eq': 2}},
                                                                                   {'room_num': {'$eq': 1}}]},
                                                                'inputStage': {'advanced': 24886,
                                                                               'direction': 'forward',
                                                                               'dupsDropped': 0,
                                                                               'dupsTested': 0,
                                                                               'executionTimeMillisEstimate': 0,
                                                                               'indexBounds': {'created': ['[new '
                                                                                                           'Date(1603065600000), '
                                                                                                           'new '
                                                                                                           'Date(1603149780000)]']},
                                                                               'indexName': 'created_1',
                                                                               'indexVersion': 2,
                                                                               'invalidates': 0,
                                                                               'isEOF': 1,
                                                                               'isMultiKey': False,
                                                                               'isPartial': False,
                                                                               'isSparse': False,
                                                                               'isUnique': False,
                                                                               'keyPattern': {'created': 1},
                                                                               'keysExamined': 24886,
                                                                               'multiKeyPaths': {'created': []},
                                                                               'nReturned': 24886,
                                                                               'needTime': 0,
                                                                               'needYield': 0,
                                                                               'restoreState': 194,
                                                                               'saveState': 194,
                                                                               'seeks': 1,
                                                                               'seenInvalidated': 0,
                                                                               'stage': 'IXSCAN',
                                                                               'works': 24887},
                                                                'invalidates': 0,
                                                                'isEOF': 1,
                                                                'nReturned': 16591,
                                                                'needTime': 8295,
                                                                'needYield': 0,
                                                                'restoreState': 194,
                                                                'saveState': 194,
                                                                'stage': 'FETCH',
                                                                'works': 24887},
                                                 'invalidates': 0,
                                                 'isEOF': 1,
                                                 'nReturned': 16591,
                                                 'needTime': 8295,
                                                 'needYield': 0,
                                                 'restoreState': 194,
                                                 'saveState': 194,
                                                 'stage': 'SUBPLAN',
                                                 'works': 24887},
                             'executionSuccess': True,
                             'executionTimeMillis': 79,  # 选择查询计划和执行查询所需的总时间(以毫秒为单位)
                             'nReturned': 16591,  # 符合查询条件的文档数。
                             'totalDocsExamined': 24886,  # 查询执行期间检查的文档数。
                             'totalKeysExamined': 24886},  # 扫描的索引条目数。
          'ok': 1.0,
          'queryPlanner': {'indexFilterSet': False,  # 一个布尔值,指定MongoDB是否对查询应用了索引过滤器。
                           'namespace': 'yq_info.monitor',  # 一个字符串,它指定<database>.<collection>要对其运行查询的集合名称
                           'parsedQuery': {'$or': [{'$and': [{'room_num': {'$eq': 1}},
                                                             {'created': {
                                                                 '$lte': datetime.datetime(2020, 10, 19, 23, 23)}},
                                                             {'created': {
                                                                 '$gte': datetime.datetime(2020, 10, 19, 0, 0)}}]},
                                                   {'$and': [{'room_num': {'$eq': 2}},
                                                             {'created': {
                                                                 '$lte': datetime.datetime(2020, 10, 19, 23, 23)}},
                                                             {'created': {
                                                                 '$gte': datetime.datetime(2020, 10, 19, 0, 0)}}]}]},
                           'plannerVersion': 1,
                           'rejectedPlans': [],
                           'winningPlan': {'inputStage': {'filter': {'$or': [{'room_num': {'$eq': 2}},
                                                                             {'room_num': {'$eq': 1}}]},
                                                          'inputStage': {'direction': 'forward',
                                                                         'indexBounds': {'created': ['[new '
                                                                                                     'Date(1603065600000), '
                                                                                                     'new '
                                                                                                     'Date(1603149780000)]']},
                                                                         'indexName': 'created_1',
                                                                         'indexVersion': 2,
                                                                         'isMultiKey': False,
                                                                         'isPartial': False,
                                                                         'isSparse': False,
                                                                         'isUnique': False,
                                                                         'keyPattern': {'created': 1},
                                                                         'multiKeyPaths': {'created': []},
                                                                         'stage': 'IXSCAN'},
                                                          'stage': 'FETCH'},
                                           'stage': 'SUBPLAN'}},
          'serverInfo': {'gitVersion': '7e28f4296a04d858a2e3dd84a1e79c9ba59a9568',
                         'host': '0.0.0.0',
                         'port': 27017,
                         'version': '4.0.19'}}

 

posted @ 2020-10-22 11:28  烧刘病  阅读(137)  评论(0编辑  收藏  举报
回到页首