Skip to content

Instantly share code, notes, and snippets.

View alexey-svistunov's full-sized avatar

Alexey Svistunov alexey-svistunov

View GitHub Profile
@molotovbliss
molotovbliss / save-large-data-quick.php
Last active September 12, 2018 15:10
Magento: One model save to rule them all for performance!
<?php
// Insert or read all data in one big batch, smallest possible number of queries.
// Sauce: http://inchoo.net/dev-talk/thou-shalt-not-do-inserts-in-a-foreach-unless-you-know-the-trick/
/*** Speed tests say (time in seconds):
100 iterations 1000 iterations 10000 iterations
Insert multiple 0.017 0.079 0.379
Foreach in a transaction 0.074 0.501 4.701