title: slow read query causes other c3p0 threads to block on acquireStatement
body: <p>I have a table <code>articles</code> with 500k rows. I only use <code>select</code> queries on it via a web app. All of my pages load fast (~20ms) and each consists of one or two fast queries (~10ms each). Those fast queries may either select something from the <code>articles</code> table or do something irrelevant, like selecting a row from another small table (5 rows).</p>
  
  <p>I am having 30 pageviews per second on this webapp with no problem.</p>
  
  <p>Sometimes though a specific page executes a select query which is very slow (~30 seconds) because it almost does a full table scan on the 500k rows of the <code>articles</code> table and just returns 3 rows. When this happens the other fast pages start slowing down heavily and at some point they completelly block.</p>
  
  <p>Note that all pages use transactions and all the queries are <code>select</code>s so they shouldn't affect each other to much, performance wise.</p>
  
  <p>I also validate the above by executing this slow query manually from a console (outside of the scope of the webapp) and the fast pages from the webapp are not affected at all. So I think that something weird is going on in the application layer.</p>
  
  <p>Any idea why does this happen? Why are all threads waiting at <code>com.mchange.v2.c3p0.stmt.GooGooStatementCache.acquireStatement</code>?</p>
  
  <p>Some data:</p>
  
  <ul>
  <li>MySQL: 5.5.32</li>
  <li>engine: InnoDB</li>
  <li>jdbc driver: mysql-connector-java-5.1.26-bin.jar</li>
  <li>pool: c3p0-0.9.1.2.jar</li>
  <li>orm: hibernate 3.6.8</li>
  <li>pool config: <a href="http://pastebin.com/3zMARM1B" rel="nofollow">http://pastebin.com/3zMARM1B</a></li>
  <li>thread dump while stuck: <a href="http://pastebin.com/YGisWCzY" rel="nofollow">http://pastebin.com/YGisWCzY</a></li>
  <li>tomcat: tomcat-6.0.32</li>
  <li>jdk: 1.6.xx</li>
  </ul>