[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2272?page=c...
]
Yves Galante commented on HHH-2272:
-----------------------------------
Hi,
I have make a new patch and a new test case (file 3 & 4) on hibernate trunk, and I
have running Junit of the testsuite projet.
This patch optimize cascading operation by caching relation parent-child on a map.
Differently by the previous patch after cascading the map is cleaned.
eventSource.getPersistenceContext().addChildParent(child, parent);
action.cascade(eventSource, child, entityName, anything, isCascadeDeleteEnabled);
eventSource.getPersistenceContext().removeChildParent(child);
The test case save and flush 10 * 551 objects.
Before patch save object with cascading is more slow when session size grows.
After patch time of save stay same at each loop.
Output of the test case before the patch :
Save took 449 ms
Save took 669 ms
Save took 1042 ms
Save took 1464 ms
Save took 2481 ms
Save took 2741 ms
Save took 3807 ms
Save took 4344 ms
Save took 4975 ms
Save took 5251 ms
Total took 30906 ms
Output after the patch
Save took 445 ms
Save took 144 ms
Save took 164 ms
Save took 108 ms
Save took 93 ms
Save took 93 ms
Save took 93 ms
Save took 94 ms
Save took 91 ms
Save took 89 ms
Total took 4905 ms
Serious performance problems when saving large amount of transient
entities with collections of transient entities
------------------------------------------------------------------------------------------------------------------
Key: HHH-2272
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2272
Project: Hibernate3
Issue Type: Task
Components: core
Affects Versions: 3.2.0.ga
Environment: Hibernate 3.2.0 on Oracle 9.2
Reporter: Markus Heiden
Attachments: hack.patch, hibernate.zip, Number of call.jpg, patchCascading.patch,
SaveTest.zip
When saving many (e.g. 50000) transient entities with a collection of transient entities,
for each collection element the whole persistence context is searched (by
StatefulPersistenceContext#getIndexInOwner() and StatefulPersistenceContext#getOwnerId)
and its even searched twice when the collection is an indexed collection. This leads to an
enormous amount (> 1000000) of iterations over all entities and over all collection
elements of each entity. Especially when one saves only the same type of entities this
leads to times of hours(!) even on a fast machine before any insert statement is even
issued. This issue is related to HHH-1612, but fixing issue HHH-1612 won't resolve
this problem (I have explored this with a hack which fixes HHH-1612).
In my eyes there are two ways to solve this problem:
1) When cascading the save of a parent, the parent cascade can fill the persistence
context with information about its collection elements. E.g. before cascading the save to
a collection a parent can add a (child, parent) pair to a map in the persistence context
to avoid the above described iterations. Then a simple Map#get() would be sufficient in
most cases to get the parent.
2) When cascading, the parent has to be passed with the cascaded (e.g. saved) element.
But this is no good solution, because it affects some well known hibernate apis.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira