Commit 2d68876
committed
Fixed N+1 loading tax categories during tax calculation
Calculating order taxes read each line item's tax category through its
variant and, when the variant had none, through its product. With the
associations unloaded that meant two queries per line item, every time
taxes were recalculated.
Preloading the variant and product for all line items keeps that load
constant regardless of how many items the order has.1 parent 8d781ac commit 2d68876
2 files changed
Lines changed: 15 additions & 0 deletions
File tree
- core
- app/models/spree/tax_calculator
- spec/models/spree/tax_calculator
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
79 | 92 | | |
80 | 93 | | |
0 commit comments