Reputation: 6048
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 always getting a timeout error when I attempt to do this. So I have two questions:
Upvotes: 3
Views: 2594
Reputation: 8237
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.
Upvotes: 5