title: Slow MySQL Performance & Sleep queries
body: <p>Recently I've been noticing very slow loading of AJAX data on my website in the early hours of the day. Using the Web Developer feature in Chrome browser, the usual speeds of 300-500ms Wait and 100-300ms Receive can increase up to 5 seconds! The site uses jQuery, Codeigniter/PHP and MySQL.</p>
  
  <p>I checked with the support desk of my VPS and they mentioned about having too many sleep queries. </p>
  
  <pre><code>There are many sleep queries for the database 'databasename'.
  
  | 4341 | mysqluser | 204.197.252.106:48669 | databasename | Sleep | 19 | | |
  | 4373 | mysqluser | 204.197.252.106:59966 | databasename | Sleep | 78 | | |
  | 4387 | mysqluser | 204.197.252.106:34807 | databasename | Sleep | 46 | | |
  | 4388 | mysqluser | 204.197.252.106:35099 | databasename | Sleep | 6 | | |
  | 4390 | mysqluser | 204.197.252.106:35452 | databasename | Sleep | 26 | | |
  | 4391 | mysqluser | 204.197.252.106:35589 | databasename | Sleep | 7 | | |
  | 4392 | mysqluser | 204.197.252.106:35680 | databasename | Sleep | 19 | | |
  | 4393 | mysqluser | 204.197.252.106:36264 | databasename | Sleep | 12 | | |
  | 4394 | mysqluser | 204.197.252.106:36327 | databasename | Sleep | 11 | | |
  </code></pre>
  
  <p>Is this the cause of the slowdowns in the morning? How can I find out what's causing the slowdown and get rid of it?</p>