Tuesday 11:50 a.m.–12:15 p.m.

But, why is the admin slow?

Jacinda Shelly

Audience level:

Novice

Description

This talk covers how to use django-debug-toolbar to find and remove performance bottlenecks related to common admin usage. As your database grows, if you're seeing 1000s of database hits for every page load, you may be tempted to scrap the admin. Before you do that, attend this talk! We'll talk about what not to put in your callables, how using list_select_related can save your bacon, and more.

Abstract

This is the general outline I'm working from so far. I think this could change slightly as I develop the talk, but this outline conveys the general theme.

Introduction and display of basic django-debug-toolbar usage (2 min)

Things the admin does well (3 min)

  • Makes development very fast
  • For many use cases, it "does the right thing" automatically. For example, modifying the HTML in a callable won't cause new queries.

What can sneak up on you (5 min)

  • Having lots of related items visible in the list view
  • Using list_select_related
  • Overriding queryset for additional select_related and prefetch_related options

What to avoid in callables (3 min)

  • Queries that will be executed on every row

The default widgets for many-to-many and foreign key fields (3 min)

  • What widgets to use to replace the defaults based on how many options you have in your database

Custom aggregates in the list view (i.e. custom querysets) (3 min)

  • When this is a good idea
  • When this is too slow and you need other options

More general performance improvements through caching (3-5 min)

  • Django's caching framework
  • Caching with third-party packages / tools
  • Custom caching with Redis

Questions (Remaining time)