Bad performance: audited entity updates (lots of them) with no EntityManager clear

Description

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;
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;
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.

Environment

Hibernate 3.6.6, Oracle

Activity

Show:
Adriano Saturno Muniz
August 29, 2011, 9:14 PM
Edited

Some corrections...

For 100,000 editions:
6h (without clear)
3min (with clear)

For 1,000,000 editions:
too slow to test (without clear)
30min (with clear)

Lukasz Antoniak
September 8, 2011, 11:12 PM
Brett Meyer
March 7, 2014, 10:07 PM

Bulk closing tickets resolved in released versions

Assignee

Lukasz Antoniak

Reporter

Adriano Saturno Muniz

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure