title: NHibernate performance insert
body: <p>I'm doing some tests with nhibernate and I'm modifying batch_size to get bulk inserts.</p>
  
  <p>I'm using mssql2005 and using the northwind db.
  I created 1000 object and insert them to the database. I've changed the values of batch_size from 5 to 100 but found no change in the performance. I'm getting value of around 300ms. Using the sql profiler, I see that 1000 sql insert statements at the sever side. Please help.</p>
  
  <h2>app.config</h2>
  
  <pre><code> &lt;property name="adonet.batch_size"&gt;10&lt;/property&gt;
  </code></pre>
  
  <h2>Code</h2>
  
  <pre><code>    public bool MyTestAddition(IList&lt;Supplier&gt; SupplierList)
      {
          var SupplierList_ = SupplierList;
          var stopwatch = new Stopwatch();
          stopwatch.Start();
          using (ISession session = dataManager.OpenSession())
          {  
              int counter = 0;
              using (ITransaction transaction = session.BeginTransaction())
              {
  
                  foreach (var supplier in SupplierList_)
                  {
                      session.Save(supplier);                       
                  }
                 transaction.Commit(); 
              }
  
          }
          stopwatch.Stop();
          Console.WriteLine(string.Format("{0} milliseconds. {1} items added",
                              stopwatch.ElapsedMilliseconds,
                              SupplierList_.Count));
          return true;
      }
  </code></pre>