MineSkin / api.mineskin.org

Source of the MineSkin API
https://api.mineskin.org
MIT License
50 stars 5 forks source link

Poor /get/list performance, possibly due to countDocuments #296

Closed roccodev closed 3 years ago

roccodev commented 3 years ago

Uncached requests of the /get/list/[page] endpoint take very long (> 20 s) to load.

I suspect this is caused by the use of countDocuments (introduced in https://github.com/MineSkin/api.mineskin.org/commit/7c1fc1b2188ed4ba3031505581149552cc44578a).

From the MongoDB docs:

Returns the count of documents that match the query for a collection or view. The method wraps the $group aggregation stage with a $sum expression to perform the count.

On the other hand, the count operation returns an estimated count, but using collection metadata.

Was there any reason for the change?

InventivetalentDev commented 3 years ago

count is deprecated. I'll look into changing it to an estimate

roccodev commented 3 years ago

Ah, I guess the Node.js library deprecated it in favour of the clearer estimatedDocumentCount / countDocuments.

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.