[wp-trac] [WordPress Trac] #46243: WordPress Comments Core Query

WordPress Trac noreply at wordpress.org
Wed Feb 13 03:48:45 UTC 2019


#46243: WordPress Comments Core Query
--------------------------+-----------------------------
 Reporter:  Uranbold      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  5.0.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Hello,

 **Issue:** We have over 400K+ posts and I saw this slow query on any
 WordPress area on each page.

 We had 2M+ comments.

 **Question:** This Query is working on all pages on Dashboard or Settings,
 Plugin section and any sections why does it? It should works on only all
 Posts list?

 **Solution:** I have noticed that Header Bar has Comments Icon and that
 has displayed the Pending Comments count. I have tried to disable it via
 custom Filter for following.

 {{{
 function admin_bar_remove_comments(){
         global $wp_admin_bar;
         $wp_admin_bar->remove_menu('comments');
 }
 add_action( 'wp_before_admin_bar_render', 'admin_bar_remove_comments' );
 }}}


 **Slow Query:**
 {{{
 SELECT comment_approved, COUNT( * ) AS total
 FROM wp_comments
 GROUP BY comment_approved
 }}}

 **Environment Information:**

 WP Version 5.0.3 (also tested 4.9.8)
 Theme: Twenty Seventeen (other themes)
 Plugins: Query Monitor

 Thanks.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46243>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list