From 829e03f6443f4dd3ad40839af9a1b21d4b010fe5 Mon Sep 17 00:00:00 2001 From: Jylpah Date: Wed, 14 Apr 2021 21:02:43 +0300 Subject: [PATCH] get_db_tank_stats(): optimize find() for index --- analyze_wotb_replays.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyze_wotb_replays.py b/analyze_wotb_replays.py index 9d860ee..2336e2d 100755 --- a/analyze_wotb_replays.py +++ b/analyze_wotb_replays.py @@ -2029,7 +2029,7 @@ async def get_db_tank_stats(db : motor.motor_asyncio.AsyncIOMotorDatabase, stat_ project[stat] = True project['_id'] = False - cursor = dbc.find({ '$and': [ { 'account_id': account_id }, { 'last_battle_time': { '$gte': battletime - time_buffer }}, { 'tank_id' : tank_id } ] }, projection=project).sort('last_battle_time',-1).limit(1) + cursor = dbc.find({ '$and': [ { 'tank_id' : tank_id }, { 'account_id': account_id }, { 'last_battle_time': { '$gte': battletime - time_buffer }} ] }, projection=project).sort('last_battle_time',-1).limit(1) # pipeline = [ { '$match': { '$and': [ { 'account_id': account_id }, { 'last_battle_time': { '$lte': battletime + time_buffer }}, { 'tank_id' : tank_id } ]}}, # { '$sort': { 'last_battle_time': -1 }},