title: Oracle 11g - query appears to cache even with NOCACHE hint
body: <p>I'm doing some database benchmarking in Python using the cx_Oracle module. To benchmark results, I'm running 150 unique queries and timing the execution of each one. I'm running something like this:</p>
  
  <pre><code>c = connection.cursor()
  starttime = time.time()
  c.execute('SELECT /*+ NOCACHE */ COUNT (*) AS ROWCOUNT FROM (' + sql + ')')
  endtime = time.time()
  runtime = endtime - starttime
  </code></pre>
  
  <p>Each query is passed in through the variable <code>sql</code>, and they vary significantly in length, runtime, and the tables they access. That being said, all queries exhibit the following behavior:</p>
  
  <p><strong>1st run:</strong> very slow (relatively)</p>
  
  <p><strong>2nd run:</strong> significantly faster (takes anywhere from 1/2 - 1/5 the time)</p>
  
  <p><strong>3rd run:</strong> marginally faster than 2nd run</p>
  
  <p><strong>All subsequent runs >= 4:</strong> approximately equal to 3rd run</p>
  
  <p>I need the cache disabled to get accurate results, but the first few runs are really throwing off my data; it's as if <code>NOCACHE</code> isn't working at all... what's going on here?</p>
  
  <p>Edit: Allan answered my question, but for anyone who might be interested, I did a little more research and came across these two pages which were also helpful:</p>
  
  <p><a href="https://stackoverflow.com/questions/2147456/how-to-clear-all-cached-items-in-oracle">How to clear all cached items in Oracle</a></p>
  
  <p><a href="http://www.dba-oracle.com/t_flush_buffer_cache.htm" rel="nofollow noreferrer">http://www.dba-oracle.com/t_flush_buffer_cache.htm</a></p>