Since the index increased and the unintended index hit first and slowed down, it became necessary to give hint and specify the index. I can't change the data structure, so I'll take care of it from now on. c⌒ ゚ д ゚) tsu φ Memo Memo ...
spec = {
'user_id': {'$in': user_id_list},
'type': 'a',
'status': 0,
'at': {'$lte': datetime.datetime.utcnow()}
}
cursor = db.collection.find(spec)
cursor.sort('at', -1).limit(500)
cursor.hint([
('at', pymongo.DESCENDING),
('user_id', pymongo.ASCENDING),
('type', pymongo.ASCENDING),
('status', pymongo.ASCENDING),
('_id', pymongo.DESCENDING),
])