NHibernate free timeout while batch insert

I am trying to insert about 16,000 records into one table. Since it is very slow, I would like to insert them into the package. However, I always get a timeout error when I try to do this. Therefore, I have two questions:

  • What is the best way to speed up inserts?
  • How to increase connection timeout?
+3
source share
1 answer

You must use a stateless session first. Instead of calling OpenSession (); (in a factory session) you call OpenStatelessSession (); It has the same api as a regular session, but there is no caching and more (much faster for bulk data operations). Then you need to set the batch size by calling .AdoNetBatchSize ([[batch size]]); where you install the database in your configuration.

This can do the trick. But you should know that this is not a relay for which nhibernate (or any other orm) is created, so do not count on any performance.

+5
source

Source: https://habr.com/ru/post/1729286/


All Articles