WooCommerce Checkout Speed and the wp_postmeta Table

How WooCommerce storing orders in wp_postmeta adds queries at checkout on large stores, and what moving to HPOS tables changed on one project.

· 2 min read · Erik Kubica

For years, WooCommerce stored orders in a database schema that was originally designed in 2004 for blog posts.

Every customer order was inserted into wp_posts with post_type = 'shop_order'. And every attribute of that order (billing address, shipping phone number, payment transaction ID, currency code, coupon discounts, order totals, tracking links) went into wp_postmeta.

On a small shop selling twenty handmade coffee mugs a week, you will probably never notice.

On a store with 400,000 lifetime orders, wp_postmeta can hold 18 million rows, and that's where I started seeing problems.

What Checkout Looked Like on Large Stores

When a shopper places an order with three products in the cart, WooCommerce has to record roughly seventy distinct metadata keys.

Because wp_postmeta is a generic entity-attribute-value (EAV) table with four columns (meta_id, post_id, meta_key, meta_value), storing and retrieving an order takes dozens of individual key lookups:

-- Legacy WooCommerce: Looking up 40 attributes sequentially
SELECT meta_key, meta_value 
FROM wp_postmeta 
WHERE post_id = 98412 
  AND meta_key IN (
    '_order_total', '_order_tax', '_billing_email', 
    '_billing_first_name', '_shipping_address_1', '_payment_method'
  );

During a Black Friday promotion with sixty concurrent checkout attempts, MySQL on one store I worked on was handling over 1,200 individual query executions per second against this one fragmented table.

The post_id index helps, but meta_value is an unindexed longtext column. The InnoDB buffer pool kept churning as active pages were pushed out of memory. Database response times went from about 4 ms to 1,600 ms, transactions started deadlocking, and some shoppers gave up at the checkout step.

That setup is a poor fit for transactional order data, which is why I was glad to see WooCommerce address it.

High-Performance Order Storage (HPOS)

When WooCommerce rolled out High-Performance Order Storage (HPOS), I moved the larger client stores I look after to it.

HPOS replaces the wp_posts / wp_postmeta combination with dedicated relational tables:

-- HPOS: Normalized order schema with proper indexing
CREATE TABLE wp_wc_orders (
    id bigint unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    status varchar(20) NOT NULL,
    currency varchar(3) NOT NULL,
    total_amount decimal(26,8) NOT NULL,
    customer_id bigint unsigned NOT NULL,
    billing_email varchar(320) NOT NULL,
    date_created_gmt datetime NOT NULL,
    KEY status (status),
    KEY customer_id (customer_id),
    KEY date_created_gmt (date_created_gmt)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Related data now lives in sibling tables: wp_wc_order_addresses, wp_wc_order_operational_data, and wp_wc_orders_meta.

Fetching an order no longer means scanning an 18-million-row metadata table. It becomes a single indexed SELECT against wp_wc_orders.

During the transition, WooCommerce provides a dual-write synchronization mode. Older third-party shipping and fulfillment plugins that still call get_post_meta() keep working, while checkout writes to the new tables. Once those plugins are updated or replaced, you can switch the authoritative store and turn synchronization to the old wp_posts table off. Check every plugin you depend on before you do.

Numbers From One Migration

I migrated an apparel retailer with 520,000 orders from legacy postmeta storage to HPOS. On that store:

  • Database Queries Per Checkout: Went from 142 SQL queries down to 18.
  • Order Placement Latency: Dropped from 3,850 ms to 220 ms.
  • Peak Database CPU Utilization: Fell from 92% to 26% under similar concurrent checkout traffic.
  • Table Size on Disk: The active order indexing footprint was 64% smaller.

Results will differ per store, plugins and hosting. For me, though, it was one of the more worthwhile changes on a large WooCommerce shop.

Tell me what you need built

Usually a reply within a day, by email or WhatsApp.