I'm trying to analyze slow queries on my system and I read that I should enable the "Slow Query Log'. I curious how I can I view this log when I'm using an instance of MySQL hosted on Amazon Web Service's RDS.
Mysql – AWS RDS MySQL / Slow Query Log
amazon-rdsMySQL
Best Answer
Did you know there is slow log table? It is called
mysql.slow_log
:There are two variables you must activate to start recording slow queries in mysql.slow_log:
Here is the situation
log_output is already defaulted to
TABLE
. You will need to enable slow_query_log. Here is what you must do:If your RDS Instance has no DB Parameter Group...
If your RDS Instance has DB Parameter Group...
Once the Instance has been restarted, login to mysql and run this query
Since the default for long_query_time is 10 seconds, the query
SELECT SLEEP(15);
should show up inmysql.slow_log
. Read the RDS Documentation to see if there are any limits on the table.CAVEAT
Here is a fair warning. Notice
mysql.slow_log
is a CSV file. The table has no key. While you can query the table, it will do full table scans. It would be great if you can do the following:Then, you can query very fast for date and time ranges. I tried to run this and I get this:
Check the RDS Documentation to see if Amazon can do this for you.
Give it a Try !!!