What is HPOS?
High-Performance Order Storage (HPOS), also known as Custom Order Tables, is a modern database architecture for storing WooCommerce orders. Instead of using WordPress posts, HPOS uses dedicated database tables optimized for e-commerce operations.HPOS is the future of order storage in WooCommerce and is enabled by default in WooCommerce 8.2+.
Why HPOS?
Problems with Post-Based Storage
Traditionally, WooCommerce stored orders as WordPress custom post types (shop_order). This approach had limitations:
- Performance: Post meta queries are slow at scale
- Database bloat: Excessive meta table growth
- Complexity: Order data scattered across multiple tables
- Maintenance: WordPress table optimization affects orders
HPOS Benefits
Better Performance
Optimized queries and indexes for faster order retrieval and updates.
Scalability
Handle millions of orders without performance degradation.
Data Integrity
Proper foreign keys and constraints ensure data consistency.
Simpler Queries
Direct SQL queries without post meta complexity.
Database Tables
HPOS introduces four new database tables:Core Tables
Compatibility Modes
HPOS supports three compatibility modes:1
Posts Storage (Legacy)
Orders are stored as WordPress posts. Default for WooCommerce < 8.2.
2
Compatibility Mode
Orders are stored in both posts and custom tables. Useful during migration.
3
HPOS (Recommended)
Orders are stored only in custom tables. Best performance.
Enabling HPOS
Admin Interface
1
Navigate to Settings
Go to WooCommerce > Settings > Advanced > Features
2
Enable High-Performance Order Storage
Check the box for “Enable High-Performance Order Storage”
3
Run Migration
Click “Update” to save settings. WooCommerce will begin migrating orders.
Programmatic Control
Developer Guide
Working with Orders
The WooCommerce order API remains the same regardless of storage method:Using the WooCommerce CRUD methods ensures compatibility with both storage systems.
Direct Database Queries
If you must query the database directly, use theOrdersTableDataStore class:
Handling Custom Order Meta
Custom meta data works the same way:Extension Compatibility
Testing Your Extension
1
Enable HPOS
Test your extension with HPOS enabled.
2
Enable Compatibility Mode
Test with both storage methods synchronized.
3
Test Data Migration
Migrate orders back and forth between storage methods.
4
Test Direct Queries
If using direct SQL, ensure queries work with both storage types.
Common Compatibility Issues
Issue: Direct wp_posts queries
Issue: Direct wp_posts queries
Problem: Code queries
wp_posts directly for shop_order post type.Solution: Use WooCommerce CRUD methods:Issue: Using get_post_meta() for orders
Issue: Using get_post_meta() for orders
Problem: Using WordPress post meta functions directly.Solution: Use order methods:
Issue: WordPress query functions
Issue: WordPress query functions
Problem: Using
WP_Query, get_posts(), or similar for orders.Solution: Use wc_get_orders():Declaring HPOS Compatibility
Declare that your extension is compatible with HPOS:Add this code early in your plugin’s main file, ideally in the plugin header area.
Migration Process
WooCommerce provides tools to migrate orders between storage methods:Automated Migration
When HPOS is first enabled:- Orders are migrated in batches (background process)
- Site remains functional during migration
- Progress shown in admin dashboard
- Failed orders are logged for manual review
Manual Migration Commands
Performance Considerations
Query Optimization
HPOS tables are optimized with indexes:Caching
Order objects are cached automatically:Troubleshooting
Migration Issues
Migration stuck or slow
Migration stuck or slow
Check the migration status:Resume migration:
Data inconsistencies
Data inconsistencies
Enable compatibility mode and run synchronization:
Debug Mode
Enable debug logging:Best Practices
Use WooCommerce CRUD
Always use
wc_get_order() and order methods instead of direct database access.Test Both Modes
Test your extensions with both post-based and HPOS storage enabled.
Declare Compatibility
Use
FeaturesUtil::declare_compatibility() to declare HPOS support.Monitor Performance
Check query performance after enabling HPOS to verify improvements.
Additional Resources
Next Steps
REST API Orders
Work with orders via REST API
Extension Best Practices
Learn extension development best practices