[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2272) Serious performance problems when saving large amount of transient entities with collections of transient entities

Markus Heiden (JIRA) noreply at atlassian.com
Tue Dec 5 18:48:05 EST 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2272?page=comments#action_25569 ] 

Markus Heiden commented on HHH-2272:
------------------------------------

I wrote a hack that fixes this problem. I will soon rework the hack and upload it. The hack adds in the cascade the (child, parent) pair to the persistence context. This avoids several lookups by the backref and index getters, but isn't still optimal, because for indexed collections the collection has still to searched for the index. Anyway without this hack the above testcase took 82 minutes to do the save (just the time for the save, no time for flush / commit included). With my hack it just takes 32 seconds.

> 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
>         Type: Task

>   Components: core
>     Versions: 3.2.0.ga
>  Environment: Hibernate 3.2.0 on Oracle 9.2
>     Reporter: Markus Heiden
>  Attachments: hibernate.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.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list