[wp-trac] [WordPress Trac] #34012: post_exists() results in a bad query
WordPress Trac
noreply at wordpress.org
Fri Sep 25 17:25:43 UTC 2015
#34012: post_exists() results in a bad query
-------------------------------+-----------------------------
Reporter: apokalyptik | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: trunk
Severity: normal | Keywords:
Focuses: performance |
-------------------------------+-----------------------------
The current post_exists() function in wp-admin/includes/post.php generates
a poorly performing query (makes use of no indexes) This is basically a
mirror issue to https://core.trac.wordpress.org/ticket/33871 for all the
same reasons.
The fix is a little bit different because post_date_gmt is actually not
indexed and post_date is deep inside of a compound index...
{{{#!sql
KEY `type_status_date` (`post_type`,`post_status`(1),`post_date`,`ID`),
}}}
I have attached a diff to modify post_exists such that it can take
post_type and post_status in addition to post_date and so make use of the
existing table indexes. In my testing this is almost always 2x as fast in
the optimal circumstance and massively faster in exceptionally poor
circumstances.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34012>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list