Answer the question
In order to leave comments, you need to log in
How to overclock Django ORM?
I created a model and there are a lot of ForeignKey in it. And apparently the ORM creates some kind of Joins and because of this, everything is bad with the return speed. What are some good ways to optimize? Do not offer to overclock the database - it is already all in memory.
Answer the question
In order to leave comments, you need to log in
Bring your models to 3 normal form
Then cache the answer
Then "overclock the orm"
Correctly told - it is necessary to profile requests. First you need to establish the cause. Find a brake request, check indexes, look in EXPLAIN. In my experience, Django ORM sometimes creates such queries (for example, an exception through a subquery, etc.) that the only acceptable solution is not to use the Django query builder, but to use Raw-SQL. However, I am not a big supporter of Raw-SQL , and in this case this library often helps me out for building SQL queries . If many single requests are made by links, then prefetch_related().
djbook.ru/rel1.8/topics/db/optimization.html
https://docs.djangoproject.com/en/1.8/topics/db/op...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question