Performance: Native SQL queries
MEDIUM IMPACT
Native SQL queries impact server response time and data fetching speed, which affects how fast the page can start rendering.
String sql = "SELECT id, name, email FROM users WHERE active = true LIMIT 100"; List<User> users = entityManager.createNativeQuery(sql, User.class).getResultList();
String sql = "SELECT * FROM users"; List<User> users = entityManager.createNativeQuery(sql, User.class).getResultList();
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Fetching all data without filters | N/A (server-side) | N/A | Delays initial paint | [X] Bad |
| Fetching filtered, limited data | N/A (server-side) | N/A | Speeds up initial paint | [OK] Good |