Commit 3dfcd901bc1 for woocommerce

commit 3dfcd901bc1029fd642b255aecddcd415e9dc5eb
Author: Vladimir Reznichenko <kalessil@gmail.com>
Date:   Thu Mar 26 09:42:22 2026 +0100

    Performance: add new index on wc_reserved_stock table. (#63864)

    This update introduces a new index on the wc_reserved_stock table to maintain a consistent `orders-stock reservation` join execution plan in HVM and BFCM scenarios.

diff --git a/plugins/woocommerce/changelog/performance-new-index-for-wc_reserved_stock b/plugins/woocommerce/changelog/performance-new-index-for-wc_reserved_stock
new file mode 100644
index 00000000000..83686dbb411
--- /dev/null
+++ b/plugins/woocommerce/changelog/performance-new-index-for-wc_reserved_stock
@@ -0,0 +1,4 @@
+Significance: patch
+Type: performance
+
+A new index has been added to the `wc_reserved_stock` table to maintain stock reservation performance during peak sales events.
diff --git a/plugins/woocommerce/includes/class-wc-install.php b/plugins/woocommerce/includes/class-wc-install.php
index 4f13b39780a..016b3d6c80f 100644
--- a/plugins/woocommerce/includes/class-wc-install.php
+++ b/plugins/woocommerce/includes/class-wc-install.php
@@ -2124,7 +2124,8 @@ CREATE TABLE {$wpdb->prefix}wc_reserved_stock (
 	`stock_quantity` double NOT NULL DEFAULT 0,
 	`timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
 	`expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
-	PRIMARY KEY  (`order_id`, `product_id`)
+	PRIMARY KEY  (`order_id`, `product_id`),
+	KEY product_id_expires (product_id, expires)
 ) $collate;
 CREATE TABLE {$wpdb->prefix}wc_rate_limits (
   rate_limit_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
diff --git a/plugins/woocommerce/src/Blocks/Installer.php b/plugins/woocommerce/src/Blocks/Installer.php
index 66ba6935e8c..087edd9f353 100644
--- a/plugins/woocommerce/src/Blocks/Installer.php
+++ b/plugins/woocommerce/src/Blocks/Installer.php
@@ -69,7 +69,8 @@ class Installer {
 				`stock_quantity` double NOT NULL DEFAULT 0,
 				`timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
 				`expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
-				PRIMARY KEY  (`order_id`, `product_id`)
+				PRIMARY KEY  (`order_id`, `product_id`),
+				KEY product_id_expires (product_id, expires)
 			) $collate;
 			"
 		);