0

I have an object with a cascaded list which is mapped in the following way:

HasMany(x => x.Products).Cascade.AllDeleteOrphan(); //.BatchSize(10000);

After adding 20000 products to the list, the commit takes more then 30 seconds (while it should be max 3 seconds).

What I need is a kind of bulk insert. I could follow this approach: Speed up bulk insert operations with NHibernate. I know this solution uses the StatelessSession but anyway, my hope is to configure these things in my mapping, adding objects directly to the list in my Entity and NHibernate takes care of the remaining stuff. Setting the BatchSize on the mapping of the list seems to has no effect.

Is there any way to accomplish this task in an acceptable time?

Community
  • 1
  • 1
core
  • 851
  • 1
  • 8
  • 28
  • bulk insert is not something that you need for every entity.. whenever I need it, i have created a separate extension method on stateless session `bulkInsert` which I use for this purpose – harishr Apr 02 '15 at 07:39
  • 1
    This is what I feared. But hope dies last :-) – core Apr 02 '15 at 07:49
  • if you read blogs from ayande,,, he states the same thing :0 bulk insert is not job of ORM, for that you would need specialized tools, so dont expect much from any ORM when it comes to bulk copy/upload – harishr Apr 02 '15 at 07:55

2 Answers2

0

I think that batch size in the mapping is only related to fetching. You can try using this configuration in your nhibernate config:

<property name="adonet.batch_size">250</property>
Cole W
  • 15,123
  • 6
  • 51
  • 85
  • Thanks for your reply. Unfotunately this option seems to has no effect. The commit still takes more than 30s. – core Apr 02 '15 at 07:05
0

the only to speed things up is use stateless session

(read this: Inserts of stateless session of NHibernate are slow)

also, take care of below - to make it even more faster

cfg.AutoCommentSql = false;

cfg.LogFormattedSql = false;

Community
  • 1
  • 1
harishr
  • 17,807
  • 9
  • 78
  • 125