An unindexed query gets slower as the collection grows
Locate the failed assumption, reproduce it, then repair the cause.
What actually caused it
A find on a field with no index makes MongoDB read every document in the collection. That plan is a collection scan. On a few dozen documents it still returns quickly, so the handler looks fine and the test that only checks the title stays green. As the collection grows, totalDocsExamined climbs with the number of documents, not with the number of matches. The route still returns the right row. The latency is the bug, and nothing in the body says the scan happened. Teams notice it after the data that made the scan cheap is already gone. A projection that drops unused fields does not change this plan. It only changes what comes back after the documents have been read.
Minimal reproduction
Before
const explain = await books.find({ topic: 'indexes' }).explain('executionStats');
console.log(explain.executionStats.totalDocsExamined);
The failure is silent or crashes.
The fix
Create an index on the field you actually filter or sort by, then read explain on that same filter. The plan should show an index scan, and the keys examined should sit near the number of matches instead of a collection scan of every document. Confirm the index field name matches the query. An index on a neighboring field does not speed this filter. Use a projection when you do not need every stored field, and keep that separate from the index decision. Re-run explain after the collection grows. A correct title with a collection scan is still the bug.
After
await books.createIndex({ topic: 1 });
const explain = await books.find({ topic: 'indexes' }).explain('executionStats');
console.log(explain.executionStats.totalKeysExamined);
The check happens before the damage.