Note that there are some explanatory texts on larger screens.

plurals
  1. POInserts of stateless session of NHibernate are slow
    text
    copied!<p>It's been a couple of days that I'm working on improving NHibernate Insert performance. </p> <p>I'd read in many posts (such as <a href="http://ayende.com/blog/4137/nhibernate-perf-tricks" rel="noreferrer">this one</a>) that <strong>stateless session</strong> can insert like 1000~2000 records per second.... However the best time that it could insert 1243 records is more than 9 seconds for me :</p> <pre><code>var sessionFactory = new NHibernateConfiguration().CreateSessionFactory(); using (IStatelessSession statelessSession = sessionFactory.OpenStatelessSession()) { statelessSession.SetBatchSize(adjustmentValues.Count); foreach (var adj in adjustmentValues) statelessSession.Insert(adj); } </code></pre> <p>The class :</p> <pre><code>public partial class AdjustmentValue : PersistentObject, IFinancialValue { public virtual double Amount { get; set; } public virtual bool HasManualValue { get; set; } public virtual bool HasScaleValue { get; set; } public virtual string Formula { get; set; } public virtual DateTime IssueDate { get; set; } public virtual CompanyTopic CompanyTopic { get; set; } } </code></pre> <p>Map of the class :</p> <pre><code>public class AdjustmentValueMap : ClassMap&lt;AdjustmentValue&gt; { public AdjustmentValueMap() { Id(P =&gt; P.Id); Map(p =&gt; p.Amount); Map(p =&gt; p.IssueDate); Map(p =&gt; p.HasManualValue); Map(p =&gt; p.HasScaleValue); Map(p =&gt; p.Formula); References(p =&gt; p.CompanyTopic) .Fetch.Join(); } } </code></pre> <p>Am I missing something? Any idea how to speed up the inserts?</p> <p><img src="https://i.stack.imgur.com/WYpnm.png" alt="enter image description here"></p> <p>The generated queries will be same as below :</p> <p><img src="https://i.stack.imgur.com/bDIbr.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload