Why a slow admin only shows after years
An application is usually built and tested with a small database: a few hundred orders, a handful of customers. A query that scans the whole table goes unnoticed at that size. But its duration grows with every new row. After a few years in production, the same table might hold hundreds of thousands of entries, and the same query takes seconds.
An admin slows down gradually. Every year things get a little more sluggish, nobody measures, and your team gets used to it. It only becomes obvious when something breaks off: the export, the bulk edit, the list with the “all” filter. On top of that comes clutter nobody ever cleans up, such as log tables, old sessions, abandoned carts and revisions.
The most common causes of a slow admin
Tables without the right indexes
A database index works like the index of a book: instead of reading every page, the database looks things up directly. There is almost always one for the internal ID. For the columns your team filters and sorts by in the admin, such as status, date, customer number or city, it’s often missing because those filters were added later. Then the database reads the entire table on every request. A search with a wildcard at the beginning, such as “contains Müller”, can’t make sensible use of a normal index and needs full-text search.
N+1: hundreds of single queries per list
The Laravel documentation shows the N+1 pattern with a simple example: a list of 25 books that shows the author for each book triggers 26 queries, one for the books and one per author. With eager loading, meaning loading all authors in advance with a single query, it’s two. In an order list with 50 rows showing customer, status and number of line items, this quickly turns into hundreds of queries per page view. Each one is fast; together they take time.
The N+1 pattern exists in every framework that loads database rows as objects, not just in Laravel. In Laravel, Model::preventLazyLoading() makes it visible during development: the application then stops with an error message wherever it loads data one by one, instead of quietly getting slower.
Exports and reports in the browser instead of the background
If a click in the admin starts the export directly in the browser, all the work has to be done before the response arrives. When it gets too much, the time and memory limits of PHP or the web server kick in, and the export breaks off. Often someone then clicks a second time, and the load doubles.
The better way to run exports and reports is a queue: the click only hands off the job, a background process generates the file, and your team gets a download link as soon as it’s ready.
From my own work at Unique-P: at PatchPub, patch applications and updates run through queues in the background so the interface stays responsive at all times. The reporting tool for Vertec data loads first results quickly thanks to caching and fetches current data in the background.
Counting and paging in long lists
A page counter like “Page 1 of 4,812” looks harmless in the admin, but it costs a count across the entire table on every request. Paging far back also makes the database read and discard all previous entries. With large tables, filters with an index, a precomputed counter or paging that continues from the last entry help.
Plugins, extensions and clutter
Every plugin and every extension runs along on every request in the admin. Dashboard widgets that query an external service on every load cost time on every load. In WordPress, the table of settings loaded on every request also keeps growing, including entries from plugins that were uninstalled long ago.
In WooCommerce, orders were long stored in the same tables as posts and their metadata. With HPOS (High-Performance Order Storage) they get their own tables, which according to WooCommerce means fewer read and write operations. New stores have used HPOS automatically since WooCommerce 8.2; existing ones have to switch manually, and plugins or custom code that access the old tables directly have to be adapted first. More on HPOS on the WordPress and WooCommerce page.
How to find the cause of a slow admin
You can contribute a lot to finding the cause of a slow admin, even without technical knowledge. For one week, note which page or action is slow, how long it takes, at what time and with which filter. This list shows where the search starts, and later it becomes the yardstick for before and after.
On the technical side, three tools lead to the cause of a slow admin:
- Slow query log: On request, MySQL and MariaDB log every query that takes longer than a set time. The log is off by default, and the default threshold of 10 seconds is far too high for a diagnosis. For the diagnosis, the threshold is set much lower.
- EXPLAIN: Placed in front of a query, it shows whether the database uses an index or reads the whole table, and how many rows it touches to do so.
- Profiler: Tools like Tideways, Blackfire or Xdebug show for a single request how many queries it sends, how long each function takes and where it waits for external services. For WordPress, the Query Monitor plugin shows the queries of a page; for Laravel, Telescope does something similar.
For a slow admin, measurements are taken on a copy with real data volumes. On the small development database everything is fast, which is exactly why the problem slipped through.
What waiting on a slow admin costs
- Working time: Do the math for the list your team opens most often: wait time per request times requests per day times people times business days. Add what no calculation shows: whoever waits switches windows and loses the thread.
- Failures: Exports that have to run in batches, bulk edits that break off halfway, double clicks and the rework that follows.
- Load for everyone: Admin and shop usually share the same database. A slow query in the back end ties up resources your customers in the shop are missing.
- A bigger server: More memory helps when the database no longer fits in memory. Against a missing index or hundreds of single queries it does little, but it costs money every month.
What fixing a slow admin usually involves
The causes of a slow admin usually sit in a few places, and the fixes stay local:
- Indexes for the filters and sort orders your team actually uses
- Lists without N+1, with preloaded data
- Exports, reports and bulk edits in a queue
- Log tables, sessions and clutter cleaned up by fixed rules, old records archived
- Counters and totals precomputed instead of recalculated on every request
The effect of the fix is measured before and after at the same places: load time of the list, number of queries per page, duration of the export.
Next steps for a slow admin
A slow admin is a case for Unique-P’s Make your application faster and cheaper to run service: a fixed-price diagnosis finds the slow queries and shows what fixing them will achieve. The measures follow after the diagnosis.
Unique-P’s ongoing maintenance monitors response times and slow queries, so the application stays fast as the data keeps growing. If the public site is slow as well as the admin, the guide Slow: is it the server or the frontend? helps you narrow it down.
Sources
- [1]Eloquent Relationships, Eager Loading und Preventing Lazy Loading · Laravel Documentation
- [2]Queues · Laravel Documentation
- [3]The Slow Query Log · MySQL 8.4 Reference Manual
- [4]Optimizing Queries with EXPLAIN · MySQL 8.4 Reference Manual
- [5]High-Performance Order Storage (HPOS) · WooCommerce