When you look for Django ORM optimization tips on the web, you will find mainly articles telling that you should use
prefetch_related to improve your queries.
If you are using MySQL or Amazon Aurora as a Database, you are probably using InnoDB which is the default storage engine. At Back Market, we are using Amazon Aurora and are scaling very fast. In early 2020 we opened two new countries and the number of connections is increasing every day. If it is not well designed, a database can become a bottleneck.
In the first part of the article, we will go through some of the InnoDB architecture concepts and in the second part we will see some tips and good practices improving your models for better MySQL queries performances. In this article, I’m using Django code snippets because it is the main framework we use at Back Market but understanding the InnoDB architecture is useful to all developers. …