diff --git a/plugins/woocommerce/changelog/fix-33348 b/plugins/woocommerce/changelog/fix-33348 new file mode 100644 index 00000000000..b8f6815f040 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-33348 @@ -0,0 +1,4 @@ +Significance: patch +Type: performance + +Improve memory usage in HPOS sync CLI tool. diff --git a/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php b/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php index 65446c9b870..1e955909213 100644 --- a/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php +++ b/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php @@ -219,6 +219,12 @@ class CLIRunner { $orders_remaining = count( $this->synchronizer->get_next_batch_to_process( 1 ) ) > 0; $order_count = $remaining_count - $batch_size; + + if ( function_exists( 'wp_cache_supports' ) && wp_cache_supports( 'flush_runtime' ) ) { + wp_cache_flush_runtime(); + } + + $GLOBALS['wpdb']->flush(); } $progress->finish();