~/talk

Prefetching for Fun and Profit

Talkat DjangoCon US 2019 · 2019-09-22..09-27· [databases, web-performance]
github:mwhansen
slides:none on file

Shows that Django prefetching is extensible: implement a manager/descriptor with get_prefetch_query_set returning a six-tuple and Django will batch related lookups via prefetch_related_objects. Demonstrates concrete fixes: prefetch across separate databases and non‑FK joins, conditional language‑filtered translations, and batching HTTP calls to eliminate an N+1 (example: three queries instead of 100). Provides code patterns, tests them on models and an external API, and packages reusable helpers as Django prefetch utils.

AI-written summary · about

  1. 0:00Start
  2. 1:24Overview
  3. 3:37What do I want you to get out of this talk?
  4. 5:25What is the N+1 query problem?
  5. 7:38An example from Django REST Framework
  6. 10:33Specifying Prefetches
  7. 11:38QuerySet evaluation
  8. 14:14What is a prefetcher?
  9. 18:08prefetch one level
  10. 30:01Accessing the prefetched values
  11. 32:34Multiple Databases
  12. 38:27Equal Fields
  13. 40:50Database String Translations
  14. 44:14API Requests
~/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.