[PYTHON] High Performance Django --Model

I learned a lot from reading High Perfomance Django, so a memorandum.

Reduce the number of queries

Please use this properly. During development, check the published query in the Django Debug Toolbar.

Shorter query execution time

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/

Handles small objects

If the results you get are huge, use them to improve your performance.

Query cache

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

Other

Other materials that I learned

Recommended Posts

High Performance Django --Model
Django model: ManyToManyField
Model changes in Django
Django Model Field Customization Various
Use django model from interpreter
Django Model with left outer join
Django
Automatically generate model relationships with Django
Django: Migration doesn't reflect model in DB
DJango Memo: From the beginning (model settings)
WEB application development using Django [Model definition]
Create a model for your Django schedule
Get a reference model using Django Serializer
Implement a Custom User Model in Django