Performance: Finding and querying documents
MEDIUM IMPACT
This affects server response time and how quickly the client receives data after a query.
app.get('/users', async (req, res) => { const users = await User.find({ active: true }).limit(50); res.json(users); });
app.get('/users', async (req, res) => { const users = await User.find(); res.json(users); });
| Pattern | Server Processing | Network Payload | Response Time | Verdict |
|---|---|---|---|---|
| Query all documents without filters | High (full collection scan) | Large (all data sent) | Slow (blocks response) | [X] Bad |
| Query with filters and limit | Low (uses indexes) | Small (limited data) | Fast (quick response) | [OK] Good |