Orders in WooCommerce create a lot data in the postmeta table. There’s the standard WooCommerce fields (like _order_key, _cart_hash, _billing_first_name, etc.), but payment gateway plugins, marketing integrations, and other WooCommerce plugins also generate their own metadata. It’s not unusual to see more than 60 rows of metadata for each order.
I recommend the Post Meta Inspector to easily view all the metadata on any order or post. You may be surprised how much there is!
If you run subscriptions on your site and generate a lot of renewals, WooCommerce Subscriptions may be creating a lot of unneeded metadata due to how subscriptions and renewal orders are generated. This can cause your database to grow really quickly.
WooCommerce Subscriptions copies all custom fields (i.e. metadata) set on an order during checkout to the subscription/s created for that order during checkout. When the subscription renews, Subscriptions will then copy that data to the renewal order too.
If you haven’t audited your metadata, there’s likely quite a few fields (metadata) being saved to parent orders that do not need to be copied into the subscription and then into each renewal.
A good example is “_customer_user_agent” and “_customer_ip_address”. These are pieces of metadata that really only make sense on the original parent order, and in my opinion do not need to get copied to the subscription or any renewal orders.
Many sites also have custom checkout fields like “gift_message”, “where did you hear about us” or marketing fields that should only apply to the first order. I’d suggest looking through your shop_subscription post types and shop_order renewals to see what data you’re storing but may not need.
WooCommerce Subscriptions offers two filters prevent metadata from copying: ‘wcs_subscription_meta’ and ‘wcs_renewal_order_meta’.
Here’s an example file showing how we prevent meta from copying at Universal Yums. In additional to removing meta from subscriptions and renewals, we also remove some metadata when an order completes and it is no longer needed.
If you’re interested in working on WooCommerce at scale, we’re hiring on my team at Universal Yums. Check out the job description.