[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 05:04:21 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          |  Resolution:
 Keywords:                  |     Focuses:  ui, administration, performance
----------------------------+----------------------------------------------

Comment (by Otto42):

 This query is already pretty well optimized using the existing default
 indexes.

 Example:

 `EXPLAIN SELECT COUNT( 1 ) FROM wp_posts WHERE post_type = 'post' AND
 post_status NOT IN ( 'draft' ) AND post_author = 1`

 This comes back as a SIMPLE select using the keys of type_status_date, and
 post_author, with "Using index condition" and "Using where".

 Basically, it already has indexes. The type_status_date is an index on
 post_type and post_status, with post_date there but not needed in this
 case. The post_author selection is also indexed by itself (as just
 post_author).

 If you're having issues with it, you may want to check your indexes on
 wp_posts to make sure they're all there. You can find the default keys on
 the table definition here:

 https://core.trac.wordpress.org/browser/trunk/src/wp-
 admin/includes/schema.php#L159

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50161#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list