Performance: Why database integration matters
HIGH IMPACT
This affects how quickly your web app can load and respond by managing data efficiently between the server and database.
app.get('/profile', (req, res) => { const userId = req.query.id; db.query('SELECT * FROM users WHERE id = ?', [userId], (err, results) => { if (err) throw err; res.send(results[0]); }); });
app.get('/profile', (req, res) => { const userId = req.query.id; db.query('SELECT * FROM users', (err, results) => { if (err) throw err; const user = results.find(u => u.id === userId); res.send(user); }); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Fetching all data then filtering | N/A (server-side) | N/A | N/A | [X] Bad |
| Querying only needed data | N/A (server-side) | N/A | N/A | [OK] Good |