nkorobkov / lfmsh_bank

A full-sized web accounts management system to support the virtual economy.
htpps://nkorobkov.com/projects/bank
9 stars 5 forks source link

Fix suboptimal DB queries #25

Open nkorobkov opened 4 years ago

nkorobkov commented 4 years ago

Problem Some pages load very slow I suspect that code has places where unnecessary joins are executed during page rendering.

What to do Look through the code and find all suspicious places. Fix all problems with Django object annotations https://docs.djangoproject.com/en/2.2/topics/db/aggregation/

Also: https://medium.com/@hansonkd/the-dramatic-benefits-of-django-subqueries-and-annotations-4195e0dafb16

Criteria There are no DB queries in a loop and no extra joins in the code.

nkorobkov commented 4 years ago

https://docs.djangoproject.com/en/3.0/ref/models/querysets/#django.db.models.query.QuerySet.select_related