D
D
DeFaNJI2021-11-05 19:51:12
MongoDB
DeFaNJI, 2021-11-05 19:51:12

How to speed up this feature?

There is a function to find a user in the top players (if not included in the top 10)

async function getPlaceInRating_by_winnings(id) {
const Place = await UserModel.find({}, { id: 1 })
.sort({ totalWin: -1 })
return Place.findIndex((u) => u.id == id) + 1;
}


Is it possible to speed up this code, because with a large number of documents, the execution takes too much time, so that in the end it could return the player's place in the top, for example: 6535

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question