Features

Cache Post Counts

Published · Last updated

WordPress and WooCommerce constantly want to know how many posts exist in each status: how many are published, how many are drafts, how many are pending, and so on. To work that out they run a COUNT query that scans wp_posts and groups by status. On a small site this is instant and nobody notices. On a large site with hundreds of thousands or millions of rows, that count is slow, and the real problem is that it runs constantly – every time you open the Posts or Products list screen, and repeatedly during an import as rows are added. You end up paying for the same expensive scan over and over.

The Cache Post Counts option removes that repeated work. Instead of recalculating the counts from scratch each time, it stores them in a dedicated cache table and reads them back instantly. The numbers you see on the list screens and the numbers WordPress and WooCommerce rely on internally are served from that cache rather than from a fresh scan of wp_posts. The saving is largest exactly where it hurts most: during big imports, where those counts would otherwise be recalculated on every row.

You’ll find this in the Imports tab under “Cache Post Counts”. Turn it on and the caching applies straight away.

Did you know?

The reason this option lives in the Imports tab is that the biggest saving happens during bulk imports. Each new row would otherwise trigger a fresh COUNT scan of wp_posts, so the cost of counting grows with the size of the table you are still writing to. Serving the numbers from a cache table removes that repeated scan.

If you are running large imports, this option pairs well with the wider import tuning in Diagnosing WP All Import Performance Issues with Scalability Pro. The related Cache Author and User Counts option handles the separate “Mine” and per-role counts on the same admin screens.

In short: WordPress recalculates post counts far more often than it needs to, and that scan gets expensive as your tables grow. Cache Post Counts holds the numbers in a cache table so they’re read instantly, which speeds up your imports and the Posts and Products list screens.

Further reading

cache the other uncached counts on the Posts, Products and Users screens
confirm the saving with real before-and-after numbers

Comments

▲
▼
1/1