MongoDb sort is slow with lookup collections
问题 I have two collections in my mongodb database as follows: employee_details with approximately 330000 documents which has department_id as a reference from departments collection departments collections with 2 fields _id and dept_name I want to join the above two collections using department_id as foreign key by using lookup method. Join works fine but the mongo query execution takes long time when I add sort. Note: The execution is fast If I remove the sort object or If I remove the lookup