Bug description
The recently installed Django Debug Toolbar highlighted an issue on the /v2/classes that surface while I was exploring another issue:
### SQL queries from 1 connection
- **default** 19.06 ms (135 queries including 125 similar and 113 duplicates )
Classic N+1 behaviour. However on closer investigation it doesn't seem quite the same as other N+1 errors we have encountered on the server, where the problem is clearly triggered by a specific FK being incorrectly joined or prefetched.
SELECT "api_v2_characterclass"."name",
"api_v2_characterclass"."desc",
"api_v2_characterclass"."document_id",
"api_v2_characterclass"."key",
"api_v2_characterclass"."subclass_of_id",
"api_v2_characterclass"."hit_dice",
"api_v2_characterclass"."caster_type"
FROM "api_v2_characterclass"
WHERE "api_v2_characterclass"."key" = 'srd_warlock'
LIMIT 21
125 similar queries. Duplicated 9 times.
Steps to Reproduce
- Fork the
staging branch of the Open5e API. Install deps.
- Visit the
/v2/classes endpoint in a web browser
- Investigate the Django Debug Toolbar
Bug description
The recently installed Django Debug Toolbar highlighted an issue on the
/v2/classesthat surface while I was exploring another issue:Classic N+1 behaviour. However on closer investigation it doesn't seem quite the same as other N+1 errors we have encountered on the server, where the problem is clearly triggered by a specific FK being incorrectly joined or prefetched.
Steps to Reproduce
stagingbranch of the Open5e API. Install deps./v2/classesendpoint in a web browser