Enabling MySQL Slow Query Logging for Troubleshooting Job Performance Issues

  • 7019202
  • 19-Aug-2014
  • 07-Aug-2017

Environment

MySQL

Situation

My archive jobs are running much slower than normal and loading the Retain mailbox is also slow.  What can I do to troubleshoot this?

Resolution

DISCLAIMER:
This knowledge base (KB) article is provided for informational purposes only and as a courtesy service to you, our customer. GWAVA Technical Support does not have any database administration (DBA) expertise, nor does it provide DBA services or support. GWAVA is not responsible for the results of implementing any of the concepts contained in this KB article. Implementation of any of the concepts suggested in this KB article shall be done entirely at your own and sole risk, and GWAVA does not provide any kind of warranties whatsoever resulting from your decision of implementing any of the KB article’s concepts. It is up to you to do any research and to ensure yourself that any implementation and setup of any of the KB article’s concepts in your database system is correctly and properly executed. It is imperative that you have backups of your database system and storage directory before making any implementation. If you don’t have any DBA expertise, you should consult with a DBA expert before any implementation of the KB article’s concepts.  Under no circumstances, shall GWAVA, or any of its employees, be liable, in contract, tort, delict or otherwise, whether negligence is provable or not, for any direct, indirect, incidental, special, punitive, consequential or other damages, loss, cost or liability whatsoever that would result from or are related to the implementation of any of the concepts suggested in the KB article.

To the extent permitted by applicable law, GWAVA shall not be liable to you for any special, consequential, direct, indirect or similar damages, including any loss of data, arising out from migrating any type of messages, attachments, database, metadata in your Retain system to another server and/or location.


Resolution:

There are multiple factors that can be involved with slow archive jobs, see "Archive Jobs Running Very Slowly" and "Archive Job Performance Decreases Dramatically After Retain 2 to Retain 3 Migration".  This article simply provides one troubleshooting step that can be taken with MySQL.

1.  Edit themy.cnf(Linux) or my.ini (Windows).

2.  Uncomment the following lines or add them if missing.  The log file path is a Linux path in this example:

slow-query-log = 1(this enables the setting)
slow-query-log-file = /[path]/mysql-slow.log 

The path you provide needs to be a location to which MySQL is an owner and has the appropriate permissions, so specifying the datadir would make most sense.  To find the datadir, see "How to Find Your MySQL Data Directory Containing Your Retain Database".

Example: /data/mysql-archive/mysql-slow.log 

long_query_time = 1  (specify in seconds what constitutes a slow query - in this case, it is set to 1 second because any query over 1 second is very slow)
log-queries-not-using-indexes  (this is an optional setting but it can show you if a query is not using an index, thus also pointing to a missing index problem)

3.  Restart MySQL

rcmysql restart

4.  To make reading the slow query log easier, use the mysqldumpslow command to open it:  

sudo -i mysqldumpslow /[path]/mysql-slow.log 

Its advisable to enable slow-query-log while debugging only and disable it once you are done with it.

Additional Information

This article was originally published in the GWAVA knowledgebase as article ID 2335.

Feedback service temporarily unavailable. For content questions or problems, please contact Support.