Magento 2 Inventory Reservation Performance: Fixing the Silent Checkout Killer
If you're running Magento 2 with MSI (Multi-Source Inventory) enabled — and since Magento 2.4 it's the default — you have a silent performance killer lurking in your database. The inventory_reservation table grows without bound, and every single cart operation hits it. This post walks through why this table becomes a bottleneck, how to measure the impact, and concrete steps to fix it. How Inventory Reservations Work When a customer adds a product to their cart, Magento doesn't immediately decrement stock. Instead, it creates a reservation — a record in inventory_reservation that says "this quantity is tentatively reserved for this order." The actual stock deduction happens later, when the order is placed and the shipment is processed. The flow looks like this: Add to cart → placeReservation writes a negative reservation record Place order → reservation is linked to the order Ship order → inventory_source_item is decremented, reservation should be compensated Compensation reservation → a positive record that cancels out the original negative one In theory, reservations are transient. They exist to bridge the gap between cart and shipment. In practice, they accumulate forever. The Problem: Unbounded Growth Here's what happens in production: Orders that are canceled leave orphaned negative reservations Orders that fail during checkout leave reservations that are never compensated Partial shipments create partial compensation records Quote conversions that error out mid-process leave dangling reservations Re-indexing, re-stocking, and admin edits can create duplicate records After 6–12 months of moderate traffic, the inventory_reservation table routinely hits several million rows . I've seen tables with 10M+ rows on stores doing 200 orders/day. SELECT COUNT ( * ) FROM inventory_reservation ; -- 4,872,341 rows on a store running 8 months SELECT COUNT ( * ) FROM inventory_reservation WHERE created_at < DATE_SUB ( NOW (), INTERVAL 30 DAY ); -- 4,710,882 — 96.7% of rows are