Note that there are some explanatory texts on larger screens.

plurals
  1. POsubsequent call to sql stored procedure very slow
    primarykey
    data
    text
    <p>When I call my stored procedure the first time, it executes in a few seconds. When i call it again, the exact same way, after say a minute or 2, it takes around 3-5 minutes! The stored procedure just does a run-of-the-mill Update with some where clauses, nothing extraordinary.</p> <p>I have seen other questions here, where stored procedures have run slow the first time and faster the subsequent times, so my situation really puzzles me! </p> <p>I ran the application in hibernate debug mode, and this is where it seems to take a long time, the second time around : You can see there's a 3 minute gap between the first and the second debug statement</p> <pre><code>........ //binding of other named parameters 17 Sep 2013 17:06:38,287 | DEBUG | org.hibernate.engine.query.NativeSQLQueryPlan [139] | bindNamedParameters() ABC111 -&gt; productName [1] 17 Sep 2013 17:09:39,051 | DEBUG | org.hibernate.jdbc.AbstractBatcher [418] | about to close PreparedStatement (open PreparedStatements: 1, globally: 1) </code></pre> <p>Here's how i call my stored procedure:</p> <pre><code>StringBuilder query = new StringBuilder(); query.append("{call ").append(Constants.StoreProcedures.UPDATE_ORDER_STATUS) .append("(:productName, :prodNumber, ") //other parameters .append(")} "); final String queryStr = query.toString(); Object obj = super.getJpaTemplate().execute(new JpaCallback() { public Object doInJpa(EntityManager em) throws PersistenceException { Query query = em.createNativeQuery(queryStr); query.setParameter("productName", prodBean.getProductName()); query.setParameter("prodNumber", prodBean.getProdNumber()); //other parameters return query.executeUpdate(); } }); </code></pre> <p>EDIT: On sniffing around further, i noticed that between the two calls to the stored proc in question, lets calls it SP1, another stored Proc (SP2) is called in a loop. And i face this problem only if the number of loops is high - over 400. And if i run SP1 after say 5 minutes or so, it seems to run fine - doesn't take so long. (Haven't figured out the actual threshold time gap though, after which the problem doesn't occur.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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