[wp-trac] [WordPress Trac] #21435: wp-includes/comment.php line85 causes slow query due to the non-indexed column

WordPress Trac wp-trac at lists.automattic.com
Wed Aug 1 00:31:47 UTC 2012


#21435: wp-includes/comment.php line85 causes slow query due to the non-indexed
column
-------------------------+-----------------------------
 Reporter:  matsubobo    |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  3.4.1
 Severity:  minor        |   Keywords:  has-patch
-------------------------+-----------------------------
 Following query is causes slow query if  the wp_comment table is huge.
 {{{
 $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM
 $wpdb->comments WHERE comment_author = '$author' AND comment_author_email
 = '$email' and comment_approved = '1' LIMIT 1");
 }}}

 In my case, I have 600 thousand records in the wp_comments table and the
 query takes over 10 minutes to complete.

 http://matsu.teraren.com/blog/wp-
 content/uploads/2012/08/a40b1291fd99413dc3057fbe0b792a93.png

 To fix this issue, I added index on my running wordpress and returns
 0.00sec.

 I'll attach the patch for create table file.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21435>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list