Not the answer you need?
Register and ask your own question!

How to enable general and slow query logging?

budiantoipbudiantoip Current User Role Beginner
I am about to analyze slow queries, but I'm still new to Percona, can anyone give me a clue on how to enable the general and slow query logging?

Answers

  • vaibhav_upadhyay40vaibhav_upadhyay40 Contributor Current User Role Patron
    Hi @budiantoip
    To check whether general and slow logs enabled, please use below command:
    MySQL>show global variables like "general_log%";

    MySQL>show global variables like "slow_que%";

    Also once you enable the slow_query_log you also have to check what is long_query_time:
    show global variables like "long_query%";
    Long_query_time: The value represents in seconds, for e.g. if the value is 10, this means any query which takes 10 or more than 10 seconds it will be considered as slow query and further will be logged in to the slow_query_log_file (if slow_query_log is ON/enabled).

    Hope this helps.

  • budiantoipbudiantoip Current User Role Beginner
    Hi @vaibhav_upadhyay40, thank you for your reply, I finally changed the server configuration, by adding these variables to the configuration file :
    slow_query_log = 1
    slow_query_log_file = /var/log/mysql/slow.log
    long_query_time = 1
    I was finally able to read the slow queries.
  • vaibhav_upadhyay40vaibhav_upadhyay40 Contributor Current User Role Patron
    Happy to know :)
  • sreelusreelu Current User Role Beginner
    To write general and slow query log entries only to the log tables, use --log_output=TABLE to select tables as the log destination and --general_log and --slow_query_log to enable both logs. For more visit here.

Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.