Features

Cache Author and User Counts

Published · Last updated

Some of the slowest queries in wp-admin come from counts you never asked for. On the Posts and Products screens WordPress builds the row of filter links at the top, and the “Mine” filter needs to know how many posts belong to the current user. To get that number it runs a COUNT over your posts table, uncached, on every load. The Users screen does the same sort of thing, counting how many users hold each role, also uncached. On a small site these are instant. On a site with hundreds of thousands of posts or users, each of those counts scans a large table, and you pay for it every time you open the screen.

The fix is in the WP Admin tab. “Cache author counts” and “Cache user counts” store the results of these counts so the screens can reuse them instead of recalculating from scratch on every visit.

The author-count option is worth understanding in a little more detail. To cache the “Mine” count it swaps in an optimised copy of the WordPress posts list table. Because that copy is based on WordPress core code, there’s a built-in safety check: it only activates when it confirms the copy still matches the version of WordPress you have installed. If you update WordPress and the core table has changed, the check fails and the option simply goes dormant, falling back to standard behaviour, until the plugin itself is updated to match. In other words, a WordPress update can’t break your admin screens through this feature. It just stops applying until it’s safe again.

Best for
  • Sites with hundreds of thousands of posts or products, where the “Mine” filter scan is measurable
  • Sites with a large number of registered users, where the per-role totals on the Users screen are slow
  • Anyone who lives in wp-admin all day and feels the list screens hesitate before they paint

These counts scan the same large tables that most other admin slowdowns come from, so they pair naturally with Custom Database Indexes, which give MySQL a faster path through those tables in the first place. The closely related Cache Post Counts option handles the per-status totals (“Published”, “Draft” and so on) that sit alongside the “Mine” filter on the same screens.

Why this matters

The author-count option is guarded by a version-match check because it swaps in an optimised copy of a WordPress core list table. Tying it to the core version means a future WordPress update can never break your admin screens through this feature – the worst case is that it goes dormant and falls back to standard behaviour until the plugin is updated to match.

In short: WordPress runs uncached counts to build the “Mine” filter on Posts and Products and the per-role totals on Users, and both scan large tables on big sites. The Cache author counts and Cache user counts options in the WP Admin tab cache those results, with the author-count option guarded by a version-match check so it stays dormant rather than breaking after a WordPress update.

Further reading

cache the per-status totals that sit next to the “Mine” filter on the same list screens
more ways to speed up the slow queries behind wp-admin
give MySQL a faster path through the large tables these counts scan

Comments

▲
▼
1/1