From 210e23a63dca51b146892085cb270f9908a48de7 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 9 Aug 2016 11:39:36 +0000 Subject: [PATCH] Multisite: Improve performance of the upgrade page on large networks. The query to select the next 5 blogs to upgrade was ordered by `registered`, which isn't indexed. This causes the query to table scan, which will be slow on networks with many blogs. The query only needs to be ordered by something that won't change, so ordering by `blog_id` is a good replacement. `blog_id` is indexed, and it's the only column being returned, so MySQL is able to optimize for a fast index read. Props fliespl. Fixes #37612. Built from https://develop.svn.wordpress.org/trunk@38229 git-svn-id: http://core.svn.wordpress.org/trunk@38170 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/network/upgrade.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-admin/network/upgrade.php b/wp-admin/network/upgrade.php index 199838cf57..ee8fd57545 100644 --- a/wp-admin/network/upgrade.php +++ b/wp-admin/network/upgrade.php @@ -55,7 +55,7 @@ switch ( $action ) { update_site_option( 'wpmu_upgrade_site', $wp_db_version ); } - $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A ); + $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY blog_id DESC LIMIT {$n}, 5", ARRAY_A ); if ( empty( $blogs ) ) { echo '

' . __( 'All done!' ) . '

'; break; diff --git a/wp-includes/version.php b/wp-includes/version.php index b189b57f7d..cd8150e547 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38227'; +$wp_version = '4.7-alpha-38229'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.