[eluser]JoostV[/eluser]
It seems to me you have written some 'dangerously' repetitive queries in you foreach($ids as $row) loop.
In this loop I see the follwing queries for every $row:
$result = $this->mdl_products->get();
$result = $this->mdl_product_parts->get();
$this->mdl_products->updateCalc(); is probably also a query.
This works fine if you have 10 or so $id-s. But if you have 10.000 $id-s you will run 30.000 queries in one go. Imagine what that will do to your performance. If there is any way to avoid this I would, if I were you.
Also, you attempt to load two models for every $id. Is there a special reason for this? In most cases you can build your app so a model would only have to be loaded once.
Just a thought, mind you :-)