wger icon indicating copy to clipboard operation
wger copied to clipboard

Basic Issue: Missing Database Query Optimization (N+1 Query Problem)

Open Kcodess2807 opened this issue 4 months ago • 1 comments

Use case

Description: The codebase lacks systematic use of select_related() and prefetch_related() for database query optimization. While I found one instance in the Routine.date_sequence method with proper prefetching, this pattern isn't consistently applied across the application.

Proposal

Impact: This causes N+1 query problems where the application makes multiple database queries instead of optimized joins, severely impacting performance when displaying lists of exercises, routines, or nutrition data.

Value: Implementing proper query optimization could reduce database load by 70-90% and significantly improve page load times, especially for users with large datasets.

Additional Context

No response

Kcodess2807 avatar Oct 05 '25 16:10 Kcodess2807

I am starting to work on it

inzamrzn918 avatar Oct 07 '25 18:10 inzamrzn918