Django Admin at Scale: From Milliseconds to Microseconds π
summary
Notification_log queries cause 504s for product teams when millions of rows make admin pages time out; fixes include strategic eager loading with select_related/only/defer, bulk updates plus batch processing to avoid OOM, and a custom keyset pagination using last ID instead of offset/limit. Caching querysets with Django cachops and replacing heavy foreign-key widgets with raw ID fields cuts DB load; monitoring uses Django Debug Toolbar, Silk and APMs. Response times fall from >10s to <200ms and the changes hold under real production-like data.
AI-written summary Β· about
