~/talk

Big O No: Django ORM runtime complexity and how to avoid it using LATERAL JOINS

Talkat PyCon US 2020 · 2020-04-15..04-23· [databases]
links:none on file
slides:none on file

Claims that Django can avoid N+1 and even O(n^2) query explosions by using LATERAL JOINs and correlated subqueries to run per-row aggregations and embed related rows as JSON. Demonstrates use of json_agg/json_build_array to bundle comments and a library, django-include drop-in replacement, to rehydrate models. Shows raw-SQL reduced hundreds of queries to one and shaved a couple seconds off an endpoint, but benchmarks report parity with prefetch_related in many cases and worse performance on CockroachDB for large top-level loads.

AI-written summary · about

  1. 0:00Start
  2. 4:56SQL queries can get real slow real fast
  3. 8:07Scenario 2: Many related rows
  4. 13:45Benchmarks (Postgres)
  5. 14:42Benchmarks (CockroachDB)
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.