~/talk

QuerySet.explain(): make it make sense.

Talkat PyCon Italia 2025 · 2025-05-28..05-31· [databases]
slides:none on file

Explains how PostgreSQL chooses index vs sequential scan using the cost model (seq_page_cost=1, random_page_cost=4 by default), shows using EXPLAIN ANALYZE from Django QuerySet.explain() to compare estimated vs actual rows and time, demonstrates fixes: expression indexes like upper(col) for case‑insensitive search, pg_trgm gin index plus extension for ILIKE/contains, partial indexes for low‑cardinality filters, must run ANALYZE after creating indexes, JSON index needs correct cast/type, and splitting OR queries into separate indexed subqueries yields ~5× speedup.

AI-written summary · about

  1. 0:00Introduction and background
  2. 1:35Database internals and indexing
  3. 11:10QuerySet.explain() basics
  4. 18:38Case-insensitive and GIN indexes
  5. 23:56Combining multiple indexes
  6. 26:03Performance tips and cheat sheet
  7. 27:12Q&A on migrations and analysis
~/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.