Performance: Why ORM maps Python to database
MEDIUM IMPACT
This affects how quickly data is loaded and saved between Python code and the database, impacting page load and interaction speed.
users = User.objects.select_related('profile').all() for user in users: print(user.profile.bio)
users = User.objects.all() for user in users: profile = Profile.objects.get(user=user) print(profile.bio)
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| N+1 queries with separate fetches | Minimal DOM impact | No reflows from ORM | Delays data rendering | [X] Bad |
| Optimized ORM with select_related | Minimal DOM impact | No reflows from ORM | Faster data rendering | [OK] Good |