I was supposed to find a solution for NHibernate's low performance with massive inserts.
Searching the web didn't help much and although java's version of hibernate clearly used batching efficiently, I Had to struggle the .NET Version to use the batching mode.
Basicly, an average insertion of a record took 1 mili-second (0.972113 to be precise) - Using the batching mode i've made it last just 0.06 mili-second that's a 1600% improvement!
The most crucial difference between Hibernate and NHibernate is the fact that Hibernate is able to re-order the commands once we flushed the data and set the configuration right - While NHibernate has this facility missing, not to worry - a simple solution is avilable - reorganise the savings.
So first, you should set "ado.batch_size" to the desired value, then take your list of entites and save all the low-level properties (nhibernate bags for example), then save the entity itself.
I would recommend you to turn on the NHibernate logging, and check that the similar SQL commands are tied to each other.
The final check should be at the oracle side, look for your insert at the shared pool (v$sql) and check the execution count each run - that's should do the work!
No comments:
Post a Comment