Skip to content

Administration: Let the "Mine" posts count use the type_status_author index fully - #14850

Open
mpeshev wants to merge 3 commits into
WordPress:trunkfrom
mpeshev:perf-posts-mine-count
Open

mpeshev wants to merge 3 commits into
WordPress:trunkfrom
mpeshev:perf-posts-mine-count

Conversation

@mpeshev

@mpeshev mpeshev commented Oct 25, 2026 •

Copy link
Copy Markdown

Follow-up to [60717] (#50161). The "Mine" count on posts list screens used post_status NOT IN (...), which keeps the database from using the post_author part of type_status_author (key_len 164 in #50161 comment:16). Listing the statuses shown in the All list with IN (...) lets it use all three parts (key_len 172). The statuses now go through placeholders.

Trunk's wp_posts schema, same data on both engines, median of 3:

Case MySQL 8.4.13, NOT IN to IN MariaDB 11.8.9, NOT IN to IN
author with 6,000 posts 4.3 to 4.3 ms (same plan) 3.8 to 1.0 ms
author with 6,000 posts plus 32,000 attachments and auto-drafts 26 to 2.6 ms 9.7 to 1.0 ms
one author owning all 340,000 posts 255 to 255 ms 58 to 60 ms

Never slower; up to 10x faster when the author has many rows that are not counted. Posts in unregistered statuses are no longer counted, which matches what the Mine view lists.

Trac ticket: https://core.trac.wordpress.org/ticket/58593

Testing

  • vendor/bin/phpunit --filter test_user_posts_count_counts_statuses_shown_in_all_list fails without the patch and passes with it.
  • vendor/bin/phpunit --filter Tests_Admin_wpPostsListTable passes (26 tests).

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: drafting the fix and test, and running the benchmark. I reviewed every line.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

🤖 Generated with Claude Code

…r` index fully.

`WP_Posts_List_Table` counts the current user's posts on every load of a posts list screen. The query excluded statuses with `post_status NOT IN (...)`, which keeps the database from using the `post_author` part of the `type_status_author` index added in [60717]. Depending on the engine, it reads every row of the post type in the index, or every row of the author, including attachments and auto-drafts that are not counted.

List the statuses shown in the All list with `post_status IN (...)` instead, with placeholders. The count then reads only the rows it counts, and matches what the Mine view lists, which also leaves out posts in unregistered statuses.

Follow-up to [60717].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

mpeshev and others added 2 commits October 25, 2026 19:39
… in the "Mine" count test.

The method has no effect since PHP 8.1 and is deprecated in PHP 8.5, where the test failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
See #58593.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mpeshev
mpeshev marked this pull request as ready for review October 25, 2026 18:06
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props nofearinc.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant