[wp-trac] [WordPress Trac] #50161: Slow query in WP_Posts_List_Table, no way to avoid with filters/hooks
WordPress Trac
noreply at wordpress.org
Thu May 14 02:43:29 UTC 2020
#50161: Slow query in WP_Posts_List_Table, no way to avoid with filters/hooks
---------------------------------------------+-----------------------------
Reporter: LucasMS | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 5.4.1
Severity: normal | Keywords:
Focuses: ui, administration, performance |
---------------------------------------------+-----------------------------
The post listing page on my wordpress installation is taking more than
15seconds to load (wp_posts w/ more than 120k records, running on an AWS
EC2 t2.large instance), and the main cause of this is the following query
in the constructor of class wp-admin/includes/class-wp-posts-list-
table.php:
{{{
SELECT COUNT( 1 )
FROM $wpdb->posts
WHERE post_type = %s
AND post_status NOT IN ( '" . implode( "','",
$exclude_states ) . "' )
AND post_author = %d
}}}
It is used just to count the posts the logged-in user posted and show it
over the listing table (in "Mine" link).
There is no way to filter this out or enhance the query (other than
changing this file).
Suggestion: try to create an database index for this query (I tried, but
failed), or enhance it in some way to make it faster.
Other option is to remove this "Mine (xx)" link above the listing, using
hooks.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50161>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list