title: mysql slow on first query, then fast for related queries
body: <p>I have been struggling with a problem that only happens when the database has been idle for a period of time for the data queried.  The first query will be extremely slow, on the order of 30 seconds and then related queries will be fast like 0.1 seconds.  I am assuming this is related to caching, but I have been unable to find the cause of it. </p>
  
  <p>Changing the mysql variables tmp_table_size, max_heap_table_size to a larger size had no effect except to create the temp tables in memory.</p>
  
  <p>I do not think this is related to the query itself as it is well indexed and after the first slow query, variants of the same query do not show up in the slow query log.  I am most interested in trying to determine the cause of this or a way to reset the offending cache so I can troubleshoot the issue.</p>