I learned a lot from reading High Perfomance Django, so a memorandum.
Please use this properly. During development, check the published query in the Django Debug Toolbar.
spam.count ()> 0
, butspam.exists ()
Foreign Keys Generic Foreign Keys are useful, but they sometimes throw queries with poor performance behind the scenes. Sometimes you should put your own foreign key.
cached_propety Cache is enabled for properties that are costly to execute & are called many times. https://docs.djangoproject.com/ja/1.9/ref/utils/
If the results you get are huge, use them to improve your performance.
These two were introduced in the book, but Jonny Cache has stopped development. (It seems that it can not be used with Django 1.5 or higher ...)
If you make your own, the Abstruct Cached Model introduced on gumi's blog will be helpful. Model with cache function in Django --gumi Engineer ’s Blog
Recommended Posts