Commit e876be4c61b for woocommerce
commit e876be4c61b099f8cb1b11125046007d703f3a63
Author: Vladimir Reznichenko <kalessil@gmail.com>
Date: Mon Mar 16 09:27:41 2026 +0100
[Performance] Add missing indexes to the shipping tables (#63674)
Aims to enhance cart and checkout workflow performance for complex shipping configurations, addressing slow SQL queries that do not use indexes.
diff --git a/plugins/woocommerce/changelog/performance-add-indexes-on-shipping-tables b/plugins/woocommerce/changelog/performance-add-indexes-on-shipping-tables
new file mode 100644
index 00000000000..15382188673
--- /dev/null
+++ b/plugins/woocommerce/changelog/performance-add-indexes-on-shipping-tables
@@ -0,0 +1,4 @@
+Significance: patch
+Type: performance
+
+Added the missing shipping tables indexes to improve the performance of cart and checkout workflows for complex shipping configurations.
diff --git a/plugins/woocommerce/includes/class-wc-install.php b/plugins/woocommerce/includes/class-wc-install.php
index fbfa90f5dc5..a1c0f3bb66c 100644
--- a/plugins/woocommerce/includes/class-wc-install.php
+++ b/plugins/woocommerce/includes/class-wc-install.php
@@ -2004,7 +2004,8 @@ CREATE TABLE {$wpdb->prefix}woocommerce_shipping_zones (
zone_id bigint(20) unsigned NOT NULL auto_increment,
zone_name varchar(200) NOT NULL,
zone_order bigint(20) unsigned NOT NULL,
- PRIMARY KEY (zone_id)
+ PRIMARY KEY (zone_id),
+ KEY zone_order_id (zone_order, zone_id)
) $collate;
CREATE TABLE {$wpdb->prefix}woocommerce_shipping_zone_locations (
location_id bigint(20) unsigned NOT NULL auto_increment,
@@ -2021,7 +2022,9 @@ CREATE TABLE {$wpdb->prefix}woocommerce_shipping_zone_methods (
method_id varchar(200) NOT NULL,
method_order bigint(20) unsigned NOT NULL,
is_enabled tinyint(1) NOT NULL DEFAULT '1',
- PRIMARY KEY (instance_id)
+ PRIMARY KEY (instance_id),
+ KEY zone_id (zone_id),
+ KEY method_id (method_id(20))
) $collate;
CREATE TABLE {$wpdb->prefix}woocommerce_payment_tokens (
token_id bigint(20) unsigned NOT NULL auto_increment,