glewio / glew-magento2-service

GNU General Public License v3.0
3 stars 3 forks source link

n+1 product load inefficiency #14

Open kirkmadera opened 4 years ago

kirkmadera commented 4 years ago

Looking through NewRelic traces, I see instances of Glew taking up some resources on the server. It's minor, but could be improved.

image

In \Glew\Service\Model\Types\Products::load, products are loaded, then looped through with \Glew\Service\Model\Types\Product::parse being called for each. Within there, the \Magento\Catalog\Model\Product::load method is being called 1-2 times. This is a common performance issue in M2 code.

See image

Instead, products should be loaded with the needed data via repository, then products looped through. Batching should be used to prevent memory limit issues.