Skip to content

[5.x]: Cart performance slow with 100 shipping rules (N+1 queries) #4220

@lenvanessen

Description

@lenvanessen

What happened?

Description

Every time the cart is updated, Craft Commerce evaluates ALL shipping rules to determine which ones apply, and it fetches the category conditions for each rule individually causing n+1 queries and sluggish add to cart problem).

Steps to reproduce

  1. Add many shipping rules
  2. Check the queries executed by adding a item to the cart

Expected behavior

Smarter evualition, maybe not on add to cart, or filtering relevant rules by getting them in bulk

Actual behavior

Slow, +1second add to cart

Craft CMS version

5.8.23

Craft Commerce version

5.5.2

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions