Mysql query taking 100%

Home»AWS Support Community Forum»Mysql query taking 100%

Mysql query taking 100%
Reply

Ashok Kumar

Hi,

mysql query are using 100% cpu utilization, please let me know best mysql tuning for RDS.

 

Thanks

 

This discussion contains 2 replies and has 85 views.

Replies
Reply

Arthur Schmunk

Hi,
You should care your MySQL RDS the same way as regular MySQL server. It Looks like missing indexes problem. Frist of all you need  track your slow queries:
Edit RDS parameters from AWS console:

slow_query_log=on
long_query_time=1

To apply this settings immediate, you will require RDS instance reboot.
To see if parameters applied run:
show global variables like ‘slow_query_log’;
and
show global variables like ‘long_query_time’;
To see slow logs run:
select * from mysql.slow_log
To rotate slow log run:
CALL mysql.rds_rotate_slow_log;

Also you can monitor MySQL Error Log, Slow Query Log and General Log directly through the AWS Console.

Reply

Aldrin Leal

MySQL is like living at your parents’ home: You sometimes consider leaving it, but when you consider the hosting costs, you often drop the idea quickly.

(Same applies to PHP. Hey, don’t shoot the messenger!)

The most painful part in MySQL, from my own experience, comes from Indexing. In particular, indexes are tricky to get it right, as the Query Optimizer of MySQL works by looking at the fields to scan, and trying to find a ‘best match’ between the (ordered) list of fields to scan + available indexes,

Long story made short: You’re likely to have created indexes (painful as it gets larger) which are not useful for all your queries (something with PostgreSQL done with the unexpected help of Genetic Programming)

So you need to enter in the mindset of the MySQL Query Parser, and understand how it works, specially by using EXPLAIN and Covering Indexes:

http://www.mysqlperformanceblog.com/2006/11/23/covering-index-and-prefix-indexes/

(Not sure if mytop would work)

You must be logged in to reply to this topic.