mawilson / survivor_draft

MIT License
0 stars 0 forks source link

Investigate Django Debug Toolbar #153

Closed mawilson closed 5 months ago

mawilson commented 6 months ago

Also mentioned here, this look like a handy way to troubleshoot & optimize my project.

https://github.com/jazzband/django-debug-toolbar?tab=readme-ov-file

mawilson commented 5 months ago

Working on this now, currently have the duplicated queries down by about 2/5 just by adding a couple of lines with prefetch_related & cached_property cached_property. The big offender for duplicated DB queries looks to be the points() functions within the Team & especially Survivor classes. cached_property can go on any function with just a self param, but the Survivor points function has a self & a season param, so need to look into what to do about that.

mawilson commented 5 months ago

Done in https://github.com/mawilson/survivor_draft/pull/181. In addition to installing the toolbar, I did a ton of work on optimizing the database calls, both on first try (using prefetch_related) & on subsequent tries (using cached_properties & lru_cache). This was all limited to the home view, although some of those improvements (especially with the cache) ought to carry over to other pages. The home view is the biggest resource & computation hog anyway.