title: Slow Hibernate flush
body: <p>I try to save my data to MySql(local DB) throw HibernateTemplate - </p>
  
  <pre><code>getHibernateTemplate().execute(new HibernateCallback&lt;Void&gt;() {
              @Override
              public Void doInHibernate(Session session) throws HibernateException, SQLException {
                  for (TimeInvocationStatistics stat : statistics) {
                      session.persist(stat);
                  }
                  session.persist(workloadProcessDescriptiveStatistics);
                  session.flush();
                  return null;
              }
          });
  </code></pre>
  
  <p>The size of data is not so big, but this operation takes over 60 sec. </p>
  
  <p>I tried to profile it - </p>
  
  <p><img src="https://i.stack.imgur.com/m9Xz4.png" alt="enter image description here"></p>
  
  <p>(good picture resolution - <a href="http://img-fotki.yandex.ru/get/9058/54759517.0/0_d1643_649ef8c2_XXXL.png" rel="nofollow noreferrer">picture</a> )</p>
  
  <p>As I can see session.flush() (second row in stacktrace) works slow, how I can improve it ? Could it be MySql server problems ? </p>
  
  <p>UPD: find interesting thread - <a href="https://forum.hibernate.org/viewtopic.php?f=1&amp;t=1006916" rel="nofollow noreferrer">hibernate forum</a>, try to do in this way</p>