开发者

Fluent NHibernate command timeout during batch insert

I'm trying to insert around 16000 records into a single table. Because this is very slow, I'd like to batch insert them. However, I'm alwa开发者_如何学Cys getting a timeout error when I attempt to do this. So I have two questions:

  1. What is the best way to speed up inserts?
  2. How do I increase the timeout value of the connection?


First you have to use a stateless session. Instead of calling OpenSession(); (on the session factory), you call OpenStatelessSession(); It has much the same api as the normal session, but there is not caching and stuff (a lot quicker for bulking data operations). Then you need to set the batch size by calling .AdoNetBatchSize([[batch size]]); where you set the database in your configuration.

This might do the trick. But you should know that this isn't relay what nhibernate (or any other orm) is built for, so don't count on any kind of performance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜