2025-07-25 –, Auditorium
We have tools that show what queries are executed and the time it takes. But what next? What is going on there? Is it good that it's doing that? Will some indexes help?
In this talk, I will help you decipher database query plans and give some rules of thumb to understand if the database is doing the best it can. We will learn about different ways databases retrieve the data and how they estimate the cost of those operations. We will also use query plans to find the best function-based and partial indexes for different kinds of Django filter conditions. JSON fields? We will cover those as well! I will also share several anti-patterns I have seen in Django projects and show how to rewrite them in a database-friendly way.
This might change: introduce explain plan, overview of table/index/parallel scans, nested loop/hash joins. Different approaches when we need less than 5-10% of data or more. Query cost calculation, why database will not choose multiple indexes on separate fields. Nulls in indexes, "NOT IN" queries, how to transform them into "IN" queries. Creating indexes for specific queries including the proper typecast, lower/upper/like. Using explain plan to see what index the database is looking for. Partial indexes. How active searches over multiple tables fail (OR conditions) and how to fix that (actually did it for clients and had some revelations about Postgres). Will have a demo django code for that.
Intermediate
What are the main topics of your talk? –Django, ORM, Database, Postgres
Aivars Kalvāns is a FinTech developer, software architect, and consultant. He spent more than 18 years developing and architecting payment card software for acquiring and issuing, accounting and utility payments through mobile phones, ATMs, and POS terminals. At the moment he is a contractor for Ebury exploring the Foreign Exchange area of the FinTech landscape.