Slow MySql Server Performance - What and How to check?
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 https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html
EXPLAIN Extended command shows details about your queries when your have no idea what is happening https://dev.mysql.com/doc/refman/8.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 *
Not
SELECT * FORM xTable ;
Yes
SELECT ID, Name, Addr FORM xTable ;
Make use of Query Cache https://dev.mysql.com/doc/refman/5.7/en/query-cache-configuration.html
SHOW VARIABLES LIKE 'have_query_cache';
0 意見:
張貼留言