Closed kfern closed 3 years ago
UPDATE: Using mongo shell, this queries are fast:
db.logs.find({"createdAt" : 1404205105000})
db.logs.find().limit(10).sort({ createdAt: -1 })
db.logs.find().limit(10).sort({ createdAt: 1 })
db.logs.find().sort({ createdAt: -1 }).limit(10)
db.logs.find().sort({ createdAt: 1 }).limit(10)
Have you tried the useEstimatedDocumentCount
outlined in the README? That may be helpful.
@DaddyWarbucks Thanks a lot. useEstimatedDocumentCount = true solves the problem
I have a logs collection with more than 27M records:
This collection is indexed by a timestamp field named "createdAt" at logs.class.js
I enabled mongodb profiling for testing:
A query like "{ '$limit': '10', '$skip': '0', '$sort': { createdAt: '-1' } }" is very slow:
Why this query is not using the index? ( keysExamined: 0 docsExamined: 27417057 )
Can I do something?
Steps to reproduce
Expected behavior
Fast results
Actual behavior
Slow results
System configuration
Module versions (especially the part that's not working): "@feathersjs/feathers": "^4.5.11", "feathers-mongodb": "^6.3.0", "mongodb": "^3.6.10", "mongodb-core": "^3.2.7",
MongoDB versión: Tested with 3.4 and 4.4.7 NodeJS version: 12.22.1 Operating System: Ubuntu 18.04 & Ubuntu 21.04
NOTE: The following stack works fine: