wc_update_300_comment_type_index

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.

Description

(null) wc_update_300_comment_type_index(); 

Returns (null)


Usage

  1. if ( !function_exists( 'wc_update_300_comment_type_index' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-update-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wc_update_300_comment_type_index(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-update-functions.php  
  1. function wc_update_300_comment_type_index() { 
  2. global $wpdb; 
  3.  
  4. $index_exists = $wpdb->get_row( "SHOW INDEX FROM {$wpdb->comments} WHERE column_name = 'comment_type' and key_name = 'woo_idx_comment_type'" ); 
  5.  
  6. if ( is_null( $index_exists ) ) { 
  7. // Add an index to the field comment_type to improve the response time of the query 
  8. // used by WC_Comments::wp_count_comments() to get the number of comments by type. 
  9. $wpdb->query( "ALTER TABLE {$wpdb->comments} ADD INDEX woo_idx_comment_type (comment_type)" );