Skip to main content

Posts

Showing posts from May 27, 2013

What to do if a query is logged in mysql slow query log.

On a mysql server there are a lot of queries to optimize and a lot of load generated by them. I’ll try to present the most usual optimization issues and how to identify them. First you’ll have to check mysql service settings . You can check them manually by following commands in mysql command line: mysql>show variables; or mysql>show variables like ‘%cache%’; and mysql> show status; you can check the counters and increase or decrease them according to their usage and limits. The more easy way is to use some scripts to check mysql settings like : MySQL performance tuning primer script (tuning-primer.sh). First and most important optimization is to activate and set query_cache and query_cache_size to lower disk IO usage. After that you will have to check the running queries . For that you’ll need to enable first : log-slow-queries= /var/lib/mysql/mysql-slow.log long-query-time=3 in my.cnf then touch /var/lib/mysql/mysql-slow.log and set owner as