Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DoctrineWriter Critical Performance Issue #194

Closed
Fantus opened this issue Apr 28, 2015 · 3 comments
Closed

DoctrineWriter Critical Performance Issue #194

Fantus opened this issue Apr 28, 2015 · 3 comments
Labels

Comments

@Fantus
Copy link
Contributor

Fantus commented Apr 28, 2015

Hi,

we could figure out a big performance issue related to not calling em->clear() correctly.

this issue occurs only if you init a new DoctrineWriter with a namespace alias like CompanyAppBundle:User instead of Company\AppBundle\Entity\User

Due to this issue $this->entityManager->clear($this->entityName) gets called with a "wrong" entity name so the entity wont get cleared in the entityManager which results in an exponential performance and memory issues the more items we try to import.

The maybe easiest fix:

Changing the constructor of the DoctrineWriter to translate the $entityName to the same

public function __construct(EntityManager $entityManager, $entityName, $index = null)
{
    //translate entityName in case a namespace alias is used
    $entityName = $entityManager
        ->getMetadataFactory()
        ->getMetadataFor($entityName)
        ->getName();

    $this->entityManager = $entityManager;
    $this->entityName = $entityName;

best
Justus

@ddeboer
Copy link
Owner

ddeboer commented Apr 28, 2015

Thanks for reporting! I think your fix makes sense. Can you open a PR?

@ddeboer ddeboer added the bug label Apr 28, 2015
Fantus added a commit to ecoco/data-import that referenced this issue Apr 30, 2015
@Fantus
Copy link
Contributor Author

Fantus commented Apr 30, 2015

Sure, i found a better way to fix it and added a unit test

#195

ddeboer added a commit that referenced this issue May 2, 2015
DoctrineWrite fix for issue #194
@ddeboer
Copy link
Owner

ddeboer commented May 2, 2015

Merged #195.

@ddeboer ddeboer closed this as completed May 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants