[TYPO3-mvc] How to speed up the creation of 100.000+ objects in an extbase extension?

Thomas Mammitzsch thomas at visualworx.de
Wed Dec 5 18:45:41 CET 2012


hi Roland,

Try to persist manually via persistence manager like that:

$i = 0;
foreach ($recordSet as $record) {
...

   $i++;

   if($i % 100 == 0) {
     $this->persistenceManager->persistAll();
   }
}

did that those days in flow and have about 160000 entries imported in 
around 8 minutes (via cli of course). Without that it takes ages because 
of high ram load and swapping i think.

regards, Thomas

Am 05.12.2012 17:32, schrieb Roland:

> hi everybody,
>
> i have to import 100.000+ database records from an external oracle
> database. these records should be transformed into objects of a extbase
> extension.
>
> at the moment this takes a lot of time. 60+ minutes an still waiting...
>
> is there something like a best practice to make this work faster?
>
> this is some of my code:
>
> --- quote ---
>
> foreach ($recordSet as $record) {
>    $newUser =
> $this->objectManager->create('Tx_MyExtension_Domain_Model_User');
>    $newUser->setName($record['name']);
>    $newUser->setName($record['email']);
>    $newUser->setName($record['fax']);
>    ...
>    $newUser->setName($record['phone']);
>    $newUser->setName($record['city']);
>    $newUser->setName($record['zip']);
>    $this->userRepository->add($newUser);
> }
>
> --- /quote ---
>
> how can i improve this? what about a persistAll() or should a unset()
> help somehow?
>
> kind regards
>
> roland



More information about the TYPO3-project-typo3v4mvc mailing list