title: MySQL taking high CPU Usage
body: <p>I have dedicated linux server with 4 cores and 8GB RAM. I have one webportal developed in crash php and mysql. On single page it pushing near about 15-20 queries. On each page I have included mysql connection. My Problem is everytime mysql service taking 50% cpu while sometime 160-200%. When it reaches to 200%, my server get hang and need to restart.</p>
  
  <p><code>SHOW PROCESSLIST;</code> showing no queries pending.
  I have optimized all tables using <code>OPTIMIZE TABLE</code> query. Some of tables are INNODB while some are MYISAM. I have checked slow query logs who is tracking queries greater than 1 second. There are few queries which taking time not greater than 2-3 seconds.</p>
  
  <p>my.cnf file contain</p>
  
  <pre><code>default-storage-engine=MyISAM
  innodb_file_per_table=1
  performance-schema=0
  max_allowed_packet=268435456
  slow_query_log=1
  slow_query_log_file=/var/lib/mysql/slow.log
  long_query_time=1
  log_queries_not_using_indexes=0
  log_error=/var/lib/mysql/mysql_error.log
  
  [mysqld_safe]
  log_error=/var/lib/mysql/mysql_safe_error.log
  </code></pre>