Is their any way to filter MySQL slow queries database specifically from /var/log/mysql/mysql-slow.log file. I have a mysql server with 5 live databases. I am trying to optimize this server.

Also I want to know what are the best practices for optimizing mysql server.

My settings are:

log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 5
log-queries-not-using-indexes

Solution 1:

mysqldumpslow /var/log/mysql/mysql-slow.log

That will give you a list of distinct slow and non indexed queries sorted by how many times the query has ran, most first. Run that for each log, if the query execute time is less than your slow time (5), then it's a non indexed query.

Hope this helps someone.