[wp-trac] [WordPress Trac] #61097: Filter `wp_count_posts()` query before execution to avoid slow query
WordPress Trac
noreply at wordpress.org
Sat Sep 6 11:42:44 UTC 2025
#61097: Filter `wp_count_posts()` query before execution to avoid slow query
-------------------------------------------------+-------------------------
Reporter: rcorrales | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Future
| Release
Component: Posts, Post Types | Version: 2.5
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests has-test- | Focuses:
info needs-testing | performance
-------------------------------------------------+-------------------------
Changes (by SirLouen):
* keywords: has-patch has-unit-tests => has-patch has-unit-tests has-test-
info needs-testing
* version: 6.5 => 2.5
* milestone: Awaiting Review => Future Release
Comment:
This underperforming query was added in #6052/[7109]
== Testing Information
Given that this is mostly a performance improvement, to test this is
required to add a massive volume of posts. For example, add 100,000
private posts with an administration user and 100,000 normal public posts
with the same administration user.
Then execute the `wp_count_posts` function with `$priv` `readable` but
with a different user (with author capabilities). The result should be the
50,000 posts, but the important thing here is to measure the time to
process with `microtime` with and without the patch.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61097#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list