GW2Raidar / gw2raidar

A log parsing website for Guild Wars 2 combat logs
http://www.gw2raidar.com
GNU General Public License v3.0
20 stars 14 forks source link

Remove redundant prefetch_related from restat #340

Closed Lego6245 closed 5 years ago

Lego6245 commented 5 years ago

Reading the django docs, prefetch_related and iterator are incompatible.

https://docs.djangoproject.com/en/2.2/ref/models/querysets/#prefetch-related

Note that if you use iterator() to run the query, prefetch_related() calls will be ignored since these two optimizations do not make sense together.

As such, it appears that restat is querying the DB (doing a full scan), just to get a count that's never used, and then the iterator is called, which explicitly discards the previous cached result. This should reduce some of the overhead when running restat as we work to optimize this loop further.