Skip to content

[5.x] Memoize matching shipping rule per method per request#4300

Draft
lukeholder wants to merge 2 commits into
5.xfrom
feature/5.x-shipping-matching-performance
Draft

[5.x] Memoize matching shipping rule per method per request#4300
lukeholder wants to merge 2 commits into
5.xfrom
feature/5.x-shipping-matching-performance

Conversation

@lukeholder
Copy link
Copy Markdown
Member

@lukeholder lukeholder commented May 21, 2026

Description

Performance improvements for stores with a large number of shipping rules.

  • ShippingMethod::matchOrder() and getPriceForOrder() both previously walked all shipping rules independently. The matching rule is now cached on the method instance per order so the rule list is only walked once.
  • Instead of loading all shipping rules into memory upfront, rules are now streamed from the database in batches of 200 during matching. Each rule is instantiated, tested, then discarded — peak memory is proportional to the batch size rather than the total number of rules.
  • Disabled rules are filtered out in SQL rather than in PHP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant