How to check mysql login

How can I control MySQL to detect SELECTs that are slow? Having identified a poorly performing SELECT, how would I analyze it to improve it?

+4
source share
2 answers

MySQL maintains a "slow query log" that will provide you with information about slow queries.

I think it is turned on by default, and its location is set in the MySQL.ini file.

Learn more about the slow query log here .

You can use EXPLAIN to get information about how MySQL executes your queries - just put EXPLAIN before the query. There is a good article here on how to interpret the results.

+1
source

You would include a slow query , for example. add this to your my.cnf in the [mysqld] section

 set-variable=slow_query_log=on set-variable=long_query_time=20 

This will log all requests taking 20 seconds or more, with the name "hostname" -slow.log, for example. / var / lib / mysql / localhost -slow.log

Then you check these queries and at least run EXPLAIN and find out what slows down, for example. add indexes, rewrite SQL, etc., although optimizing queries are a whole different book.

+2
source

Source: https://habr.com/ru/post/1305435/


All Articles