Hello guys.I am trying to see how many totalDocsExamined
with explain on my query,but i dont get this kind of information.I need to run execution stats
but i dont know how
This is my query
agg_pipeline=[
{"$match": {
"timestamp1": {"$gte": datetime.strptime("2020-01-01 00:00:00",
"%Y-%m-%d %H:%M:%S"),
"$lte" :datetime.strptime("2020-12-31 01:55:00", "%Y-%m-%d %H:%M:%S")},
"id13": {"$gt": 5}}},
{"$group": {
"_id": {"$dateToString": {"format": "%Y-%m-%d %H",
"date": "$timestamp1"}}}},
{"$sort": {"_id": -1}},
{ "$limit": 5},
{"$project": {
"_id": 0,
"hour":"$_id"}}
]
explain_output = mydb1.command('aggregate', 'mongodb2indextimestamp1', pipeline=agg_pipeline, explain=True)
pprint(explain_output)
And this is the the explain output:
{'ok': 1.0,
'serverInfo': {'gitVersion': '72e66213c2c3eab37d9358d5e78ad7f5c1d0d0d7',
'host': 'xaris-MS-7817',
'port': 27017,
'version': '4.4.6'},
'stages': [{'$cursor': {'queryPlanner': {'indexFilterSet': False,
'namespace': 'mongodbtime.mongodb2indextimestamp1',
'parsedQuery': {'$and': [{'timestamp1': {'$lte': datetime.datetime(2020, 12, 31, 1, 55)}},
{'id13': {'$gt': 5}},
{'timestamp1': {'$gte': datetime.datetime(2020, 1, 1, 0, 0)}}]},
'planCacheKey': '3A0C9E84',
'plannerVersion': 1,
'queryHash': 'DC05E87A',
'rejectedPlans': [],
'winningPlan': {'inputStage': {'direction': 'forward',
'indexBounds': {'id13': ['(5, '
'inf.0]'],
'timestamp1': ['[new '
'Date(1609379700000), '
'new '
'Date(1577836800000)]']},
'indexName': 'timestamp1_-1_id13_1',
'indexVersion': 2,
'isMultiKey': False,
'isPartial': False,
'isSparse': False,
'isUnique': False,
'keyPattern': {'id13': 1,
'timestamp1': -1},
'multiKeyPaths': {'id13': [],
'timestamp1': []},
'stage': 'IXSCAN'},
'stage': 'PROJECTION_COVERED',
'transformBy': {'_id': 0,
'timestamp1': 1}}}}},
{'$group': {'_id': {'$dateToString': {'date': '$timestamp1',
'format': {'$const': '%Y-%m-%d '
'%H'}}}}},
{'$sort': {'limit': 5, 'sortKey': {'_id': -1}}},
{'$project': {'_id': False, 'hour': '$_id'}}]}
Is it possible to get information about "executionTimeMillis"
"totalKeysExamined"
"totalDocsExamined"
?
Thanks in advance!