From 78feb00f7cb809e3d0ab81a1402e0d24d66290a2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 10 Dec 2019 13:45:41 +0000 Subject: [PATCH] Comments: Optimize the query for pending comments count in `wp_notify_moderator()` for better performance on large tables. Props sgoen. Fixes #48514. git-svn-id: https://develop.svn.wordpress.org/trunk@46878 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/pluggable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 3b81242f4d..5edef2d0c5 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -1739,7 +1739,7 @@ if ( ! function_exists( 'wp_notify_moderator' ) ) : $comment_author_domain = gethostbyaddr( $comment->comment_author_IP ); } - $comments_waiting = $wpdb->get_var( "SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'" ); + $comments_waiting = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails.