Add an index to the field comment_type

This index improves the response time of the query used by WC_Comments::wp_count_comments() to get the number of comments by type.
This commit is contained in:
Rodrigo Primo 2016-08-09 10:00:51 +02:00
parent ab721f2d4a
commit 2e8f02f6a4
2 changed files with 16 additions and 0 deletions

View File

@ -403,6 +403,10 @@ class WC_Install {
}
dbDelta( self::get_schema() );
// Add an index to the field comment_type to improve the response time of the query
// used by WC_Comments::wp_count_comments() to get the number of comments by type.
$wpdb->query( "ALTER TABLE {$wpdb->comments} ADD INDEX woo_idx_comment_type (comment_type)" );
}
/**

View File

@ -987,3 +987,15 @@ function wc_update_270_webhooks() {
$webhook->set_topic( 'product.updated' );
}
}
/**
* Add an index to the field comment_type to improve the response time of the query
* used by WC_Comments::wp_count_comments() to get the number of comments by type.
*
* @return null
*/
function wc_update_270_comment_type_index() {
global $wpdb;
$wpdb->query( "ALTER TABLE {$wpdb->comments} ADD INDEX woo_idx_comment_type (comment_type)" );
}