snippetsqlMinor
Slow MySql Server Performance - What and How to check?
Viewed 0 times
whatandslowmysqlperformancehowservercheck
Problem
start:disclaimer
I'm not a MySql Server DBA; I know mostly of MSSQL - which is why I need your help.
end:disclaimer
I've been asked to check why the MySql server engine is performing poorly - I have not seen nor held the databases involved and would like to know where to start.
Where do I start?
What questions should I be asking those who have access to MySql - I don't even know if they are using phpmyadmin or some other tool.
Essentially:
What are the key items to ask for when the issue is in the performance of the database?
in MSSQL I can check
* do not have to be specific as there can be many kinds of results for each item but would like to help get the ball rolling since it is affecting users - apparently they set up the mysql engine without having a dba on-board.
I'm not a MySql Server DBA; I know mostly of MSSQL - which is why I need your help.
end:disclaimer
I've been asked to check why the MySql server engine is performing poorly - I have not seen nor held the databases involved and would like to know where to start.
Where do I start?
What questions should I be asking those who have access to MySql - I don't even know if they are using phpmyadmin or some other tool.
Essentially:
- What items should I ask for and how would I respond to each piece they give?
What are the key items to ask for when the issue is in the performance of the database?
in MSSQL I can check
sp_who2 for existing connections to see if anything is blocking, what is the counterpart in mysql?* do not have to be specific as there can be many kinds of results for each item but would like to help get the ball rolling since it is affecting users - apparently they set up the mysql engine without having a dba on-board.
Solution
-
Log slow queries- If your system has a ton of queries, it gets tougher to find out which queries are slowing your system. MySQL provides a tool to log slow queries for further analysis
http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html
-
EXPLAIN Extended command shows details about your queries when your have no idea what is happening http://dev.mysql.com/doc/refman/5.0/en/explain-extended.html
Also if you are retrieving all fields from a table, the query gets slower by fetching all data from disk. In SELECT query you should specify which fields you need to bring instead to bring them all with *
http://dev.mysql.com/doc/refman/5.5/en/option-files.html
For example "Comments" fields has size of 256 characters, reply it to MYSQL with a field with type VARCHAR(256) instead of using TEXT. The query will be much faster.
Procedure_Analyse() can help you in finding optimal data types:
http://www.mysqlperformanceblog.com/2009/03/23/procedure-analyse/
http://dev.mysql.com/doc/refman/5.0/en/procedure-analyse.html
Log slow queries- If your system has a ton of queries, it gets tougher to find out which queries are slowing your system. MySQL provides a tool to log slow queries for further analysis
http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html
-
EXPLAIN Extended command shows details about your queries when your have no idea what is happening http://dev.mysql.com/doc/refman/5.0/en/explain-extended.html
- To speed up your queries use Index - A good practice is add index by seeing which fields are in the WHERE clause add index for them.
Also if you are retrieving all fields from a table, the query gets slower by fetching all data from disk. In SELECT query you should specify which fields you need to bring instead to bring them all with *
- Make use of Query Cache http://dev.mysql.com/doc/refman/5.1/en/query-cache-configuration.html
- Make sure that your MySQL server configuration file options are optimized according to your hardware
http://dev.mysql.com/doc/refman/5.5/en/option-files.html
- Make sure that you are using optimized data types while creating a table structure
For example "Comments" fields has size of 256 characters, reply it to MYSQL with a field with type VARCHAR(256) instead of using TEXT. The query will be much faster.
Procedure_Analyse() can help you in finding optimal data types:
http://www.mysqlperformanceblog.com/2009/03/23/procedure-analyse/
http://dev.mysql.com/doc/refman/5.0/en/procedure-analyse.html
- There are open source tools from Percona - http://www.percona.com/software/percona-toolkit which can be helpful for MySQL DBA's and specially those who are new to MySQL these tools will provide good assistance to them.
Context
StackExchange Database Administrators Q#53229, answer score: 9
Revisions (0)
No revisions yet.