Django 6.1.3 on SQLite (in-memory): ch01-one-request WSGIHandler: GET /editions/2026-11-25/ through desk/ WSGIHandler.__call__(PATH_INFO='/editions/2026-11-25/') signal request_started (sender=WSGIHandler) WSGIRequest.__init__(GET /editions/2026-11-25/) BaseHandler.get_response TimingHeaderMiddleware.__call__ BaseHandler._get_response URLResolver.resolve('/editions/2026-11-25/') URLResolver.resolve('editions/2026-11-25/') EditionListView.dispatch(issue_date='2026-11-25') EditionListView.get_queryset SQL SELECT "newsroom_edition"."id", "newsroom_edition"."issue_date", "newsroom_edition"."slug", "newsroom_edition"."title", "newsroom_edition"."status", "newsroom_edition"."published_at" FROM "newsroom_edition" WHERE "newsroom_edition"."slug" = %s LIMIT 21 params=('2026-11-25',) EditionListView.render_to_response -> TemplateResponse (unrendered) TemplateResponse.render(template=['newsroom/edition.html', 'newsroom/story_list.html']) Template.render('newsroom/edition.html') SQL SELECT "newsroom_story"."id", "newsroom_story"."headline", "newsroom_story"."slug", "newsroom_story"."body", "newsroom_story"."priority", "newsroom_story"."status", "newsroom_story"."published_at", "newsroom_story"."desk_id", "newsroom_story"."reporter_id", "newsroom_story"."edition_id", "newsroom_desk"."id", "newsroom_desk"."name", "newsroom_desk"."slug", "newsroom_desk"."section_code", "newsroom_reporter"."id", "newsroom_reporter"."name", "newsroom_reporter"."email", "newsroom_reporter"."desk_id", "newsroom_reporter"."user_id" FROM "newsroom_story" INNER JOIN "newsroom_desk" ON ("newsroom_story"."desk_id" = "newsroom_desk"."id") INNER JOIN "newsroom_reporter" ON ("newsroom_story"."reporter_id" = "newsroom_reporter"."id") WHERE ("newsroom_story"."edition_id" = %s AND "newsroom_story"."status" = %s) ORDER BY "newsroom_story"."priority" ASC, "newsroom_story"."id" ASC params=(2, Story.Status.PUBLISHED) SQL SELECT "newsroom_correction"."id", "newsroom_correction"."story_id", "newsroom_correction"."note", "newsroom_correction"."issued_at" FROM "newsroom_correction" WHERE "newsroom_correction"."story_id" IN (%s, %s, %s, %s) ORDER BY "newsroom_correction"."issued_at" ASC, "newsroom_correction"."id" ASC params=(1, 3, 2, 4) start_response('200 OK', headers=[Content-Type, X-Frame-Options, Content-Length, X-Desk-Ms, X-Content-Type-Options, Referrer-Policy, Cross-Origin-Opener-Policy]) HttpResponseBase.close signal request_finished (sender=WSGIHandler) done: status='200 OK' queries=3 html_bytes=1219 has_x_desk_ms=True Naive view on 4 stories (2026-11-25): 17 of 18 queries fire inside Template.render NaiveEditionListView.dispatch(issue_date='2026-11-25') NaiveEditionListView.get_queryset SQL SELECT "newsroom_edition"."id", "newsroom_edition"."issue_date", "newsroom_edition"."slug", "newsroom_edition"."title", "newsroom_edition"."status", "newsroom_edition"."published_at" FROM "newsroom_edition" WHERE "newsroom_edition"."slug" = %s LIMIT 21 params=('2026-11-25',) NaiveEditionListView.render_to_response -> TemplateResponse (unrendered) TemplateResponse.render(template=['newsroom/edition.html', 'newsroom/story_list.html']) Template.render('newsroom/edition.html') SQL SELECT "newsroom_story"."id", "newsroom_story"."headline", "newsroom_story"."slug", "newsroom_story"."body", "newsroom_story"."priority", "newsroom_story"."status", "newsroom_story"."published_at", "newsroom_story"."desk_id", "newsroom_story"."reporter_id", "newsroom_story"."edition_id" FROM "newsroom_story" WHERE ("newsroom_story"."edition_id" = %s AND "newsroom_story"."status" = %s) ORDER BY "newsroom_story"."priority" ASC, "newsroom_story"."id" ASC params=(2, Story.Status.PUBLISHED) SQL SELECT "newsroom_desk"."id", "newsroom_desk"."name", "newsroom_desk"."slug", "newsroom_desk"."section_code" FROM "newsroom_desk" WHERE "newsroom_desk"."id" = %s LIMIT 21 params=(1,) SQL SELECT "newsroom_reporter"."id", "newsroom_reporter"."name", "newsroom_reporter"."email", "newsroom_reporter"."desk_id", "newsroom_reporter"."user_id" FROM "newsroom_reporter" WHERE "newsroom_reporter"."id" = %s LIMIT 21 params=(1,) SQL SELECT "newsroom_correction"."id", "newsroom_correction"."story_id", "newsroom_correction"."note", "newsroom_correction"."issued_at" FROM "newsroom_correction" WHERE "newsroom_correction"."story_id" = %s ORDER BY "newsroom_correction"."issued_at" ASC, "newsroom_correction"."id" ASC params=(1,) SQL SELECT "newsroom_correction"."id", "newsroom_correction"."story_id", "newsroom_correction"."note", "newsroom_correction"."issued_at" FROM "newsroom_correction" WHERE "newsroom_correction"."story_id" = %s ORDER BY "newsroom_correction"."issued_at" ASC, "newsroom_correction"."id" ASC params=(1,) SQL SELECT "newsroom_correction"."id", "newsroom_correction"."story_id", "newsroom_correction"."note", "newsroom_correction"."issued_at" FROM "newsroom_correction" WHERE "newsroom_correction"."story_id" = %s ORDER BY "newsroom_correction"."issued_at" ASC, "newsroom_correction"."id" ASC params=(1,) SQL SELECT "newsroom_desk"."id", "newsroom_desk"."name", "newsroom_desk"."slug", "newsroom_desk"."section_code" FROM "newsroom_desk" WHERE "newsroom_desk"."id" = %s LIMIT 21 params=(2,) SQL SELECT "newsroom_reporter"."id", "newsroom_reporter"."name", "newsroom_reporter"."email", "newsroom_reporter"."desk_id", "newsroom_reporter"."user_id" FROM "newsroom_reporter" WHERE "newsroom_reporter"."id" = %s LIMIT 21 params=(3,) SQL SELECT "newsroom_correction"."id", "newsroom_correction"."story_id", "newsroom_correction"."note", "newsroom_correction"."issued_at" FROM "newsroom_correction" WHERE "newsroom_correction"."story_id" = %s ORDER BY "newsroom_correction"."issued_at" ASC, "newsroom_correction"."id" ASC params=(3,) SQL SELECT "newsroom_correction"."id", "newsroom_correction"."story_id", "newsroom_correction"."note", "newsroom_correction"."issued_at" FROM "newsroom_correction" WHERE "newsroom_correction"."story_id" = %s ORDER BY "newsroom_correction"."issued_at" ASC, "newsroom_correction"."id" ASC params=(3,) SQL SELECT "newsroom_correction"."id", "newsroom_correction"."story_id", "newsroom_correction"."note", "newsroom_correction"."issued_at" FROM "newsroom_correction" WHERE "newsroom_correction"."story_id" = %s ORDER BY "newsroom_correction"."issued_at" ASC, "newsroom_correction"."id" ASC params=(3,) SQL SELECT "newsroom_desk"."id", "newsroom_desk"."name", "newsroom_desk"."slug", "newsroom_desk"."section_code" FROM "newsroom_desk" WHERE "newsroom_desk"."id" = %s LIMIT 21 params=(1,) SQL SELECT "newsroom_reporter"."id", "newsroom_reporter"."name", "newsroom_reporter"."email", "newsroom_reporter"."desk_id", "newsroom_reporter"."user_id" FROM "newsroom_reporter" WHERE "newsroom_reporter"."id" = %s LIMIT 21 params=(2,) SQL SELECT "newsroom_correction"."id", "newsroom_correction"."story_id", "newsroom_correction"."note", "newsroom_correction"."issued_at" FROM "newsroom_correction" WHERE "newsroom_correction"."story_id" = %s ORDER BY "newsroom_correction"."issued_at" ASC, "newsroom_correction"."id" ASC params=(2,) SQL SELECT "newsroom_desk"."id", "newsroom_desk"."name", "newsroom_desk"."slug", "newsroom_desk"."section_code" FROM "newsroom_desk" WHERE "newsroom_desk"."id" = %s LIMIT 21 params=(3,) SQL SELECT "newsroom_reporter"."id", "newsroom_reporter"."name", "newsroom_reporter"."email", "newsroom_reporter"."desk_id", "newsroom_reporter"."user_id" FROM "newsroom_reporter" WHERE "newsroom_reporter"."id" = %s LIMIT 21 params=(4,) SQL SELECT "newsroom_correction"."id", "newsroom_correction"."story_id", "newsroom_correction"."note", "newsroom_correction"."issued_at" FROM "newsroom_correction" WHERE "newsroom_correction"."story_id" = %s ORDER BY "newsroom_correction"."issued_at" ASC, "newsroom_correction"."id" ASC params=(4,) TRAP naive 4-story run: queries=18 html_bytes=1219 identical_html=True Naive vs. eager view: 4 stories vs. 200 stories (query counts and byte parity) view stories in_view in_template total_sql html_bytes naive 4 1 17 18 1219 eager 4 1 2 3 1219 TRAP naive 200 1 641 642 36394 eager 200 1 2 3 36394 identical_html_4=True identical_html_200=True No identity map: two queries for the same Story return distinct Python objects SQL SELECT "newsroom_story"."id", "newsroom_story"."headline", "newsroom_story"."slug", "newsroom_story"."body", "newsroom_story"."priority", "newsroom_story"."status", "newsroom_story"."published_at", "newsroom_story"."desk_id", "newsroom_story"."reporter_id", "newsroom_story"."edition_id" FROM "newsroom_story" WHERE "newsroom_story"."slug" = %s LIMIT 21 params=('bridge-bond-passes',) SQL SELECT "newsroom_story"."id", "newsroom_story"."headline", "newsroom_story"."slug", "newsroom_story"."body", "newsroom_story"."priority", "newsroom_story"."status", "newsroom_story"."published_at", "newsroom_story"."desk_id", "newsroom_story"."reporter_id", "newsroom_story"."edition_id" FROM "newsroom_story" WHERE "newsroom_story"."slug" = %s LIMIT 21 params=('bridge-bond-passes',) first == second -> True first is second -> False after mutating first.headline: second.headline -> 'Bridge bond passes council' queries=2 Live census of the booted desk/ project installed_apps=8 middleware=8 registered_models=15 db_tables=18 root_url_patterns=6 seeded rows: desks=3 reporters=4 beats=3 editions=2 stories=6 (published=5) story_beats=8 corrections=3 subscriptions=3