Building effective Django queries with expressions
summary
Claims that query expressions scale: on a 500,000‑row example raw approaches take ~4s while expression‑based queries run ~0.32s, and the project has tables with more than ten million records. Shows concrete tools used: Q objects, F expressions, Case/When and ExpressionWrapper, plus database functions like Concat, Coalesce and Extract. Demonstrates annotations (add 56 days, compute missing bags, annotate full_name on a manager) that remove denormalized fields and fix stale data — the changes work and improve performance.
AI-written summary · about
chapters (30)
- 0:00Introduction
- 0:49Vanessas background
- 1:25Vita Software
- 1:47Open Source
- 2:02Call a question
- 2:23Django 14 years old
- 3:09Normalization
- 4:43Pure Expressions
- 5:43Query Objects
- 6:35Complex Filters
- 7:16Tip
- 7:45Search
- 9:09Query without query
- 9:29SQL parse
- 9:59F expressions
- 11:09F objects
- 13:28Expression wiper
- 13:53Unique queries
- 14:18Summary
- 14:30Database Functions
- 16:08Concatenation
- 17:12Annotation
- 17:50Colley
- 18:27KnowIf
- 18:56NoLeaf
- 19:09Conditional logic
- 19:39Discount logic
- 21:17Database functions cast
- 21:50Conditional expressions
- 22:20References
related talks
17mOff the Beaten Path: Exploring Unusual Roads to Django Performance
27mDjango - Customise your SQL
29mMaking smarter queries with advanced ORM resources
46mPostgreSQL Beyond Django: Strategies to Get Max Performance with Álvaro Justen
16mBig O No: Django ORM runtime complexity and how to avoid it using LATERAL JOINS
30mQuerySet.explain(): make it make sense.
30mBeyond faceted search
45mSQL Indexing Beyond Simple Columns: Expressions, Text Fragments, Attributes J...
