PyCon GR 2025

Off the Beaten Path: Exploring Unusual Roads to Django Performance
2025-08-30 , Auditorium "Miltiadis Evert"

I’ve been working as a backend developer for four years. In my current role, I work with large datasets—millions of rows and complex queries. Simple Django tips like select_related or caching are often not enough. In this talk, I will share real solutions I’ve used in production to improve performance using Django and PostgreSQL together.

As Django projects grow, performance issues start to appear. Queries slow down, pagination gets laggy, and advanced database features become necessary. This talk will focus on four advanced but practical techniques that help keep Django fast and clean—even with large amounts of data.

First, I’ll show how to use materialized views in PostgreSQL and how to connect them to Django models. They are great for speeding up heavy queries, especially in reports or analytics. I’ll explain how to create, refresh, and use them in Django without breaking the ORM.

Next, we’ll look at when using subqueries instead of DISTINCT can bring better performance. I’ll show clear examples comparing both approaches and explain when choosing subqueries might be more efficient.

Then, I’ll introduce the new GeneratedField feature from Django 5. This allows you to define fields whose values are automatically computed by the database based on other fields in the same model. Unlike properties or annotations, GeneratedField ensures that the computed value is stored and maintained at the database level, leading to improved performance and data consistency. I’ll explain how it works and share how we've started using it in our projects.

Finally, I’ll cover window functions, especially ROW_NUMBER(), and how to use them together with Django’s ORM tools like OuterRef and Subquery for smarter and faster queries.

This talk is for Django developers who already know the basics and want to go further—especially those working with big data and real-world performance problems. You’ll leave with ideas, patterns, and code you can start using right away.

I am a Backend Developer with 4 years of active experience, specializing in Python/Django and related technologies. Throughout my career, I've worked on diverse projects involving large datasets, focusing on developing clean, well-documented web APIs. I am passionate about sharing my knowledge and experiences within the backend development community, which I do through writing articles on Medium.