[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1) Optimize Hibernate for the bulk insertion of related entities

Martin Ross (JIRA) noreply at atlassian.com
Sat Nov 25 16:09:05 EST 2006


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

Martin Ross commented on HHH-1:
-------------------------------

There are a few points highlighted in this case:

1)  compareTo() contract requires transitivity to be satisfied. Assume a<b<c  then  a.compareTo(b) == a.compareTo(c).  For complex object graphs we cannot do this unless we traverse the object graph.  The proposed implementation does not do this.
2)  This traversal of the object graph must be done from both directions: this -> other and other -> this .  The proposed implementation does not do this.
3)  Inverse relationships add another wrinkle.  A can have association to B, but A should actually be inserted before B.

It seems that any implementation (unless someone smarter than me can comment on this) will require an algorithm similar to this:
-Determine if there is a path from A to B OR if there is a path from B to A
- If so then examine path to determine if A should be inserted before B or B should be inserted before A

The good news is that my current implementation (that does not satisfy transitive property) in the cases that it does not work makes a large difference in performance.  Another point is that the I think the worse case performance of the entire merge sort will be very roughly n log n*m^2 where n is number of items in the action queue and m is the number of classes in the object graph.  Both m and n will typically very small so it shouldn't be a huge deal.  Presumably caching the results of compareTo() between any two class can chop another order of magnitude off the performance.

Anyways, my thoughts..  Please feel free to prove me wrong, etc..  Also if someone who knows the hibernate code well can suggest an easy way to derive the path between two objects I would love to hear from them :)


> Optimize Hibernate for the bulk insertion of related entities
> -------------------------------------------------------------
>
>          Key: HHH-1
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1
>      Project: Hibernate3
>         Type: New Feature

>   Components: core
>  Environment: Hibernate 1.2, MySql 3.1
>     Reporter: Bradley Leupen
>     Priority: Minor

>
>
> It is currently difficult to batch the creation of persistent entities that maintain associations with other entities.
> Add necessary api to hibernate to support the save or update of a collection of entities. An optimization can be applied in this scenario to group inserts / updates by entity class, or table. This will enable the hibernate engine to utilize batching if available, drastically improving performance over a network. 

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