title: Hibernate performance tuning for multiple similar select queries
body: <p>The problem I have is that I have lots of similar queries in a batch:</p>
  
  <pre><code>select id, a, b, c from records where a = 1 and b = 2
  select id, a, b, c from records where a = 5 and b = 3
  select id, a, b, c from records where a = 2 and b = 5
  select id, a, b, c from records where a = 3 and b = 4
  ...
  </code></pre>
  
  <p>a batch normally consists of 1000 queries, which takes about 0.5s to finish, with a and b indexed. Auto commit is on and all connections are managed in bonecp connection pool. Hibernate is used to map each result into an object instance.</p>
  
  <p>My questions are:<br>
  1. Is it gonna make a difference if I combine them in a single query, even all db connections are live and the service doesn't need to wait for the connection to be established?<br>
  2. If yes, what's the best practice to do that in hibernate?<br>
  3. If not, is it gonna make a difference if I execute all the queries concurrently (instead of one by one in the current case), though the connection pool only allows a certain number of queries to be executed at the same time?</p>