Skip to main content

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.
Compatibility mode has a performance overhead due to dual writes.
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 the OrdersTableDataStore class:
Direct database queries bypass WooCommerce’s data layer and may break with future updates. Use WooCommerce CRUD methods whenever possible.

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

Problem: Code queries wp_posts directly for shop_order post type.Solution: Use WooCommerce CRUD methods:
Problem: Using WordPress post meta functions directly.Solution: Use order methods:
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:
  1. Orders are migrated in batches (background process)
  2. Site remains functional during migration
  3. Progress shown in admin dashboard
  4. Failed orders are logged for manual review

Manual Migration Commands

Performance Considerations

Query Optimization

HPOS tables are optimized with indexes:
Use these indexed columns in queries for best performance:

Caching

Order objects are cached automatically:

Troubleshooting

Migration Issues

Check the migration status:
Resume migration:
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