title: SELECT 1 from DUAL: MySQL
body: <p>In looking over my Query log, I see an odd pattern that I don't have an explanation for.</p>
  
  <p>After practically every query, I have "select 1 from DUAL".  </p>
  
  <p>I have no idea where this is coming from, and I'm certainly not making the query explicitly.</p>
  
  <p>The log basically looks like this:</p>
  
  <pre><code>    10 Query       SELECT some normal query
      10 Query       select 1 from DUAL
      10 Query       SELECT some normal query
      10 Query       select 1 from DUAL
      10 Query       SELECT some normal query
      10 Query       select 1 from DUAL
      10 Query       SELECT some normal query
      10 Query       select 1 from DUAL
      10 Query       SELECT some normal query
      10 Query       select 1 from DUAL
      ...etc...
  </code></pre>
  
  <p>Has anybody encountered this problem before?</p>
  
  <p>MySQL Version: 5.0.51</p>
  
  <p>Driver: Java 6 app using JDBC. mysql-connector-java-5.1.6-bin.jar</p>
  
  <p>Connection Pool: commons-dbcp 1.2.2</p>
  
  <p>The validationQuery was set to "select 1 from DUAL" (obviously) and apparently the connection pool defaults testOnBorrow and testOnReturn to true when a validation query is non-null.</p>
  
  <p>One further question that this brings up for me is whether or not I actually <strong>need</strong> to have a validation query, or if I can maybe get a performance boost by disabling it or at least reducing the frequency with which it is used.  Unfortunately, the developer who wrote our "database manager" is no longer with us, so I can't ask him to justify it for me. Any input would be appreciated. I'm gonna dig through the API and google for a while and report back if I find anything worthwhile.</p>
  
  <p>EDIT: added some more info</p>
  
  <p>EDIT2: Added info that was asked for in the correct answer for anybody who finds this later</p>