[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-6614) Bad performance: audited entity updates (lots of them) with no EntityManager clear

Adam Warski (JIRA) noreply at atlassian.com
Wed Sep 14 06:21:05 EDT 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6614?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adam Warski updated HHH-6614:
-----------------------------

    Fix Version/s: 3.6.8

> Bad performance: audited entity updates (lots of them) with no EntityManager clear
> ----------------------------------------------------------------------------------
>
>                 Key: HHH-6614
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6614
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: envers
>    Affects Versions: 3.6.6
>         Environment: Hibernate 3.6.6, Oracle
>            Reporter: Adriano Saturno Muniz
>            Assignee: Lukasz Antoniak
>             Fix For: 4.0.0.CR3, 3.6.8
>
>         Attachments: src.zip
>
>
> I was testing Envers performance.
>  
> I created an audited entity Mailmen, with a many-to-many relationship with another audited entyty, Address.
>  
> Mailmen has a simple field called register. (and an Address collection, but lets simplify the code)
>  
> I just created a new instance of Mailmen and edited it 100.000 times:
>  
> configurationOverrides = new HashMap<String, String>();
> emf = Persistence.createEntityManagerFactory("jpa", configurationOverrides);
> entityManager = emf.createEntityManager();
>  
> int MAX_EDITIONS = 1000000;
> carteiroDefault = new Mailman();
> carteiroDefault.setRegister(64737);
> entityManager.persist(carteiroDefault);
>   
> for(int i = 1; i <= MAX_EDITIONS; i++) { 
>           entityManager.getTransaction().begin();
>           carteiroDefault.setRegister(i);
>           entityManager.getTransaction().commit();
> }
>  
> It tooks about 6 hours to run this code.
>  
> It gets better or worse depending on MAX_EDITIONS, in a non linear way. Bad.
>  
> But, if I change the for block to this:
>  
>      entityManager.getTransaction().begin();
>      entityManager.find(Mailman.class, carteiroDefault.getId()).setRegister(i);
>      entityManager.getTransaction().commit();
>      entityManager.clear();
>  
> It tooks 30 minutes.
>  
> It gets better or worse depending on MAX_EDITIONS, in a linear way. Much better.
>  
> There's no bad performance without Envers in this scenario.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list