danslo/ApiImport

Stock Import - time consuming

Closed this issue · 5 comments

The stock Import for about 7000 skus is by far the most CPU & DB query time consuming process we have monitored on our system (Mage 1.9.0.1). The analysis through New Relic showed quite clearly how various slow select statements are executed in the process of loading the products by sku. Maybe a threshold would be useful at this point favoring either loading the full collection of stock items with joined skus and iterating through them during the import process against loading each item for itself.

It basically does what core Import/Export does, but looking at _saveStockItem you're probably right.

So I have a proposed solution in this branch:
https://github.com/danslo/ApiImport/tree/preload-stock

Particularly this diff:
8e21d5d

Could you try it for me and see if it alleviates your load?

Now that was quick! Thanks in advance! I'm excited about testing it out as soon as I get to work in about 3 hrs :)

Looking good so far! The system load was way lower with the optimized _saveStockItem method. At the same time we didn't experience any downsides when importing minor stock changes.
newrelic_stock_import_analysis

Thanks so far. Looking forward to seeing your change merged into the master branch.

Nice! Merging :-)