Inside the ORM
summary
Claim: the ORM query layer was rewritten three times and the final code ships in Django 1.0. It actually builds a Pythonic query.py/query class that accumulates filters, joins and select columns and only emits SQL in as_sql, with database specifics pushed into DB backends. Real issues solved: expensive cloning of QuerySets, the setup_joins hotspot that manages aliases and outer vs inner joins, correct many‑to‑many excludes (via subselects), select_related fixes, and groundwork for aggregates, multiple DBs and deferred/only field loading.
AI-written summary · about
chapters (16)
- 0:00Start
- 4:49django/db/models/query.py
- 6:16django/db/backends
- 8:16QuerySet method
- 8:54Model Managers
- 16:27Flow: QuerySet -- Query
- 17:57Flow: Query -- QuerySets
- 23:06Internal Examples
- 25:42DateQuerySet
- 30:21Query.add_filter
- 31:40Query.setup_joins
- 40:24Tricky Things
- 47:11Coming Soon(-ish)
- 49:18Extensions
- 52:50Existing Plumbing
- 53:56Missing Plumbing
related talks
30mLeave Your Inhibitions at the Database Connection
37mNo More Raw SQL with SQLAlchemy and ORMs
16mBig O No: Django ORM runtime complexity and how to avoid it using LATERAL JOINS
52mThe SQL inside the ORM/Builder box | Claudio Zizza
29mMaking smarter queries with advanced ORM resources
21mCustom Model Managers and QuerySets: Graduating from Django Beginner to ORM Master
30mThe magic of SQLAlchemy
39mLet's Build an ORM
