Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wp admin comments screen performance #4571

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/wp-admin/includes/class-wp-comments-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,9 @@ protected function comment_type_dropdown( $comment_type ) {
foreach ( $comment_types as $type => $label ) {
if ( get_comments(
array(
'number' => 1,
'type' => $type,
'number' => 1,
'orderby' => 'none',
'type' => $type,
)
) ) {
printf(
Expand Down
3 changes: 2 additions & 1 deletion src/wp-admin/includes/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
KEY comment_date_gmt (comment_date_gmt),
KEY comment_parent (comment_parent),
KEY comment_author_email (comment_author_email(10))
KEY comment_author_email (comment_author_email(10)),
KEY comment_type (comment_type)
) $charset_collate;
CREATE TABLE $wpdb->links (
link_id bigint(20) unsigned NOT NULL auto_increment,
Expand Down
12 changes: 12 additions & 0 deletions src/wp-admin/includes/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,11 @@ function upgrade_630() {
delete_option( 'can_compress_scripts' );
add_option( 'can_compress_scripts', $can_compress_scripts, 'yes' );
}

global $wpdb;
$wpdb->hide_errors();
$wpdb->query( "ALTER TABLE $wpdb->comments ADD INDEX `comment_type` (`comment_type`)" );
$wpdb->show_errors();
}
}
}
Expand Down Expand Up @@ -2470,6 +2475,13 @@ function upgrade_network() {
delete_network_option( $network_id, 'site_meta_supported' );
is_site_meta_supported();
}

// 6.3.0
if ( $wp_current_db_version < 55853 ) {
$wpdb->hide_errors();
$wpdb->query( "ALTER TABLE $wpdb->comments ADD INDEX `comment_type` (`comment_type`)" );
$wpdb->show_errors();
}
}

//
Expand Down