Before directly diving in, let’s just first briefly understand what HPOS is, what problems it solves, and how your store can benefit from it?
What is High-Performance Order Storage and its benefits?
Initially, High-Performance Order Storage was called Custom Order Tables in early 2022. WooCommerce re-branded the technical term to convey not only what custom database tables for orders are, but also what purpose they serve.
As your eCommerce stores grow, they need to store more data and customer information in their databases, which was a major problem back when WooCommerce first started. Initially, WooCommerce was never meant to store or handle such a vast amount of data. Each time a consumer places an order on a WooCommerce store, it adds dozens of order data and entries to the WordPress “post_meta” database table, creating a major problem for stores that handle a huge volume of orders and eventually resulting in performance degradation.
The solution was to move the data out of the post_meta into the custom tables, which significantly reduced the total number of order insert queries by 80%, thus minimizing the order volume bottleneck. There are 3 main properties that WooCommerce is trying to improve by introducing Custom Orders Tables to WooCommerce core:
Scalability – By having dedicated tables (and therefore dedicated indexes, less busy tables, fewer read/write ops, etc), they aim to enable constituent shops of all sizes to scale further without the need for expert intervention.
Simplicity – Being independent of WP posts should help in finding where underlying data lives, understanding its structure, and allowing developers to modify WooCommerce with more finesse.
Reliability – It should be easier than before to take and restore targeted backups, implement read/write locks, and prevent race conditions.
How to get your store set up with HPOS?
HPOS is currently under development and is not yet ready for production-ready. However, WooCommerce is encouraging store owners/users to set up and test HPOS on their staging/testing environment. During the rollout, WooCommerce aims to keep this feature strictly opt-in at first, giving store owners/users enough time to make their shops compatible. To set up the testing environment, you need to follow these steps:
1. Download and install the package:
The testing zip package can be downloaded from the project release page in GitHub. After navigating to the page, click woocommerce.zip to download the testing build.
Upload this package as you would with any other release. The usual path is to add it via Plugins > Add new > Upload Plugin > Choose file > Install Now > Activate/Replace current with an updated version.
2. Enable the experimental feature:
Once your package is installed, go to WooCommerce > Settings > Advanced > Features and enable the checkbox under Experimental Features titled “Custom order tables”.
3. Create the new High-Performance Order tables
To start using the new features, you will need to create the new tables for HPOS. Go to WooCommerce > Status > Tools and find the “Create the custom orders tables” row. Click on the Create button and check for confirmation that the tables have been created.
Note: In case you took part in the previous round of testing, it is recommended you delete the order tables first to make sure the new schema gets created correctly. To delete the tables, go to WooCommerce > Status > Tools and find the “Delete the custom orders tables” row and click on Delete.
4. Set up HPOS according to your preferences
A new setting should be available to you under WooCommerce > Settings > Advanced > Custom data stores.
Select the “Use the WooCommerce orders tables” radio button to switch your Orders data store to the WooCommerce tables, then check the “Keep the posts table and the orders tables synchronized” checkbox:
Depending on the number of orders in your store, it might take a while until your WooCommerce instance will be able to switch to the new HPOS.
You can speed up the initial synchronization by executing the sync in the WP CLI environment by running wp wc cot sync command.
> wp wc cot sync
This feature is not production ready yet. Make sure you are not running these commands in your production environment.
There are 22872 orders to be synced.
Order Data Sync 100% [===========================================================================================================] 1:34 / 1:12
Success: 22872 orders were migrated in 90.777226 seconds
That’s it, if everything went smoothly then your store should now be using High-Performance Order Storage.
HPOS will become the default experience for stores with WooCommerce 8.0. Orders will stop being synchronized to posts and postmeta tables in WooCommerce 8.0 in August 2023! Data synchronization with posts/postmeta tables will be disabled so it would be better if you start testing your store early and get the best of HPOS.
1. My existing orders don’t seem to be automatically syncing. What’s wrong?
Try clicking on the Save Changes button. That should trigger the sync again. Ensure you have checked the “Keep the posts table and the orders table synchronized” checkbox.
2. Will users get the updates of extensions like WooCommerce Stripe Payment Gateway & WooCommerce Subscriptions to support HPOS?
Yes, both of these plugins are under active development to support HPOS.
3. All of my interactions with order data happen through the CRUD. Will everything continue working as expected?
If all interactions with order data happen through CRUD, then everything should work as expected, and you shouldn’t need to change anything.
4. What is the recommendation for dealing with wpdb queries where joins happen to the posts/post meta tables?
If you are joining custom metadata, then using WC_Query with meta_query param will handle both data storage types. If you are joining a meta_key, which is now migrated to a proper column in the HPOS, then you should be able to use a field_query param with the same property as a meta_query. We plan to backport this to CPT so that the same query works for both tables.
5. What if I face an issue with custom order tables and I want to switch back to posts & post_meta?
You can switch from using HPOS to post tables manually if you see an issue with the new tables. To switch back, change the ‘Data store for orders’ setting in the WC > Settings > Advanced > Custom data stores.
6. Can I downgrade the WooCommerce version to a version created before the HPOS feature was launched?
You can downgrade the WooCommerce version to a version created before the HPOS feature was launched if the sync was enabled. This is possible because when sync is enabled, WooCommerce propagates any changes to orders both to HPOS tables and to wp_posts and wp_postmeta tables.
7. I am running an APP where the store is handled by WC APIs and some custom APIs for payment gateways etc. Does my developer need to make some specific changes related to HPOS?
WC APIs internally used CRUD, so no changes would be required and HPOS should work as expected. However, for custom APIs some code changes can be expected if the code doesn’t follow WooCommerce CRUD operations.