In any database, there are a variety of logs. MySQL is no exception, there are 4 different logs, error logs, binary logs, query logs, and slow query logs in MySQL. These logs record the different aspects of the MySQL database. These 4 different log
MySQL View database operation log the query log for MySQL logs all requests for MySQL databases. Whether or not these requests have been properly executed. The default file name is Hostname.log. By default, the MySQL query log is turned off.
Use the slow query log to locate SQL statements with low execution efficiency. when the -- log-slow-queries [file_name] option is enabled, mysqld will write a log file containing all SQL statements whose execution time exceeds long_query_time. by
MySQL has five common log types: error log, binary log, query log, slow check log, and relay log.
One, error log
The error log contains four types of information:(1) Information during the process of server startup and shutdown;(2) Error message
The logs in MYSQL/MARIADB are broadly divided into the following categories:Query LogGeneral Query log:Slow query log:error LogBinary logRelay LogTransaction logA brief introduction to these kinds of logs, logs for our analysis of MySQL service has
MySQL logs mainly include: error log, query log, slow query log, transaction log, binary log;Logs are an important part of the MySQL database. The log file records the changes that occurred during the MySQL database operation, which is used to
If you are a web developer, if you want to debug your app or improve its performance, then you need to refer to various log files. Logging is the best choice to start troubleshooting. As far as the famous MYSQL database server is concerned, you need
Mysql has a function to log down and run slow SQL statements. This log is not available by default. To enable this function, modify my. cnf or add some parameters when mysql is started. If you modify it in my. cnf, add the following
1. Install Mysqlsla
The code is as follows
Copy Code
wget http://hackmysql.com/scripts/mysqlsla-2.03.tar.gzTar zvxf mysqlsla-2.03.tar.gzCD mysqlsla-2.03Perl makefile.plMakeMake install
Perl makefile.pl will
MySQL has a function is log down to run the slower SQL statement, the default is not this log, in order to open this function, to modify the my.cnf or in the MySQL boot when the add some parameters. If you modify inside the MY.CNF, add the following
The most basic is mysql's mysqlslowdump
Easy to use:
Mysqldumpslow-s c-t 20 host-slow.log
Parameters:
1.-s, sorting, c, t, l, r, and ac, at, al, and ar are sorted by query times, time, lock time, and returned records respectively. Adding a is
Enable the slow query record function. Next, let's analyze the content of the slow query:
Select count (distinct. name) from cp_paycard as a left join cp_reservation as B on. uid = B. UID where. type = 2 and B. cpparkid = '000000' and B.
As the data volume continues to grow, performance is particularly important. Perhaps after optimization and good solutions, you cannot feel the existence of performance problems, but as the data volume continues to grow,
From millions to tens of
On the From library
For example, 1000 people have run this program.
There are always a few 2 seconds to run and everyone else is a second kill.
Excuse me, have you encountered this kind of situation?
...
I also thought that it was not the
OK, go to the database log to look for, through the time, keyword batch match. All you can think of is to use it.
Let's assume that you've executed it. No? Well, either it's too simple, or you're too easy.
Copy Code code as follows:
The previous article briefly introduced the usage of the EXPLAIN statement. Today we will introduce the following:
Slow query log
Enable slow query log
Save slow query logs to the table
Slow query log analysis
Percona Toolkit
Install
A basic tutorial on querying logs and slow query logs in MySQL,
I. query logs
Query all the queries in MySQL by using "-- log [= file_name. Because all the queries, including all the select statements, are recorded, and the size is relatively large,
This article mainly introduces the MySQL log file, this article explains the error log, binary log, General query log, slow query log, InnoDB online redo log, update log and other log types and role introduction, need friends can refer to the
slow query log in MongoDB1. turn on the query log .(1) Dynamic Open , can be selective to the specified DB turn on slow query log , However, the slow query log is manually opened after the server restarts. Db.setprofilinglevel (1,300)The
The following two methods are generally used to locate SQL statements with low execution efficiency.
* Use the slow query log to locate SQL statements with low execution efficiency. When the -- log-slow-queries [= file_name] option is enabled,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.