Merge pull request #22906 from woocommerce/add/downloadable_product_permissions_index
get_downloads_for_customer performance improvement via index
This commit is contained in:
commit
f18f4082b2
|
@ -124,6 +124,10 @@ class WC_Install {
|
||||||
'wc_update_354_modify_shop_manager_caps',
|
'wc_update_354_modify_shop_manager_caps',
|
||||||
'wc_update_354_db_version',
|
'wc_update_354_db_version',
|
||||||
),
|
),
|
||||||
|
'3.6.0' => array(
|
||||||
|
'wc_update_360_downloadable_product_permissions_index',
|
||||||
|
'wc_update_360_db_version',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -692,7 +696,8 @@ CREATE TABLE {$wpdb->prefix}woocommerce_downloadable_product_permissions (
|
||||||
PRIMARY KEY (permission_id),
|
PRIMARY KEY (permission_id),
|
||||||
KEY download_order_key_product (product_id,order_id,order_key(16),download_id),
|
KEY download_order_key_product (product_id,order_id,order_key(16),download_id),
|
||||||
KEY download_order_product (download_id,order_id,product_id),
|
KEY download_order_product (download_id,order_id,product_id),
|
||||||
KEY order_id (order_id)
|
KEY order_id (order_id),
|
||||||
|
KEY user_order_remaining_expires (user_id,order_id,downloads_remaining,access_expires)
|
||||||
) $collate;
|
) $collate;
|
||||||
CREATE TABLE {$wpdb->prefix}woocommerce_order_items (
|
CREATE TABLE {$wpdb->prefix}woocommerce_order_items (
|
||||||
order_item_id BIGINT UNSIGNED NOT NULL auto_increment,
|
order_item_id BIGINT UNSIGNED NOT NULL auto_increment,
|
||||||
|
|
|
@ -1932,3 +1932,25 @@ function wc_update_354_modify_shop_manager_caps() {
|
||||||
function wc_update_354_db_version() {
|
function wc_update_354_db_version() {
|
||||||
WC_Install::update_db_version( '3.5.4' );
|
WC_Install::update_db_version( '3.5.4' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new user_order_remaining_expires to speed up user download permission fetching.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function wc_update_360_downloadable_product_permissions_index() {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$index_exists = $wpdb->get_row( "SHOW INDEX FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE key_name = 'user_order_remaining_expires'" );
|
||||||
|
|
||||||
|
if ( is_null( $index_exists ) ) {
|
||||||
|
$wpdb->query( "ALTER TABLE {$wpdb->prefix}woocommerce_downloadable_product_permissions ADD INDEX user_order_remaining_expires (user_id,order_id,downloads_remaining,access_expires)" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update DB Version.
|
||||||
|
*/
|
||||||
|
function wc_update_360_db_version() {
|
||||||
|
WC_Install::update_db_version( '3.6.0' );
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue