As BCE's client base and file volume grew, two modules started showing their age: the virtual folder system and client management. Pages that used to load instantly were starting to lag.
Profiling turned up the usual suspects, but at scale: N+1 queries firing on every list view, permission checks running one row at a time, and large folder downloads loading an entire ZIP into memory before sending anything to the browser. None of it was broken — it just hadn't been built for the data volume it was now handling.
Query optimization across both modules using select_related and prefetch_related to collapse N+1 patterns into single queries. Large folder downloads were rewritten to stream the ZIP directly to the client instead of assembling it fully in memory first. Permission checks were batched into bulk lookups, and targeted database indexes were added on the columns those views actually filter and sort by.
Instrument the slow views to see where time was actually going, rather than guessing.
Apply select_related and prefetch_related wherever N+1 patterns showed up, turning dozens of queries into one.
Rewrite large folder downloads to stream the ZIP as it's built instead of assembling it fully in memory first.
Add indexes only on the columns the slow queries were actually filtering and sorting by.
None of this shipped as a visible feature — nobody sees a changelog entry for "pages load faster." But it's the difference between BCE staying usable as the client base grows and slowly becoming the thing everyone quietly complains about.