Commit 03575b85f88 for woocommerce
commit 03575b85f889773f42f13e141ffb5a43cb34060b
Author: Vladimir Reznichenko <kalessil@gmail.com>
Date: Tue Apr 7 13:58:08 2026 +0200
[Performance] Orders: added `transaction_id` index for `wc_orders` table. (#64025)
Enables performant order resolution by transaction_id when HPOS is enabled.
diff --git a/plugins/woocommerce/changelog/performance-orders-table-add-new-index b/plugins/woocommerce/changelog/performance-orders-table-add-new-index
new file mode 100644
index 00000000000..c82793c68df
--- /dev/null
+++ b/plugins/woocommerce/changelog/performance-orders-table-add-new-index
@@ -0,0 +1,4 @@
+Significance: patch
+Type: performance
+
+A new index has been added to the wc_orders table to improve the performance of order resolution by transaction ID.
diff --git a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php
index 058d7f0c3cc..96f65413003 100644
--- a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php
+++ b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php
@@ -3257,6 +3257,7 @@ CREATE TABLE $orders_table_name (
KEY customer_id_billing_email (customer_id, billing_email({$composite_customer_id_email_length})),
KEY customer_id_status (customer_id, status),
KEY billing_email (billing_email($max_index_length)),
+ KEY transaction_id (transaction_id(20)),
KEY type_status_date (type, status, date_created_gmt),
KEY parent_order_id (parent_order_id),
KEY date_updated (date_updated_gmt)