Common components of a relational databaseDatabases: DatabaseTables: TableRow: RowColumns: ColumnIndexes: IndexTrying to: viewUsers: UserPermissions: Privilege 存储过程:procedure 存储函数:function 触发器:
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
Test, textSlow query log open slow query log
Slow query logs, as the name implies, are logs that record slow query execution.
Check whether the slow query log is Enabled:
show variables like '%slow%';
Open the slow query log. The configuration file
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 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 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
The slow_query_log_file log becomes very large and it is inconvenient to analyze its input items. We want to generate a slow_query_log_file file every day and analyze the log file every day. How to cut by day? We have come up with this method to
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.
How to record MySQL slow query SQL logs
Modify the mysqld section of my. CNF:Long_query_time = 1 // defines the slow query time. 1 indicates 1 second.-- Log-Slow-queries [= file_name] // record slow query to log files-- Log-queries-not-using-indexes
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
Technical preparationHosted under the Ubuntu14.04.2 platform, based on the MYSQL5.5.46 version.Log files record the various types of MySQL database activities, as a daily location problem of the most common analysis means, MySQL database commonly
Learning Goals
MySQL Log
Binary log
Error log
Querying common logs
Slow query log
MySQL LogThe MySQL logs are divided into four categories, described below:
Error log: Logs the problem that occurs when the
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
MySQL Log Management and mysql Log Management
In MySQL, there are four different types of logs: error logs, binary logs, query logs, and slow query logs.
Error Log
The error log records information related to MySQL startup and shutdown, and serious
Objective:
Keep Empty cup spirit, use performance analysis, focus on measuring server time spent where, think 1, how to confirm that the server has reached the best performance state, 2, why a statement is not fast enough, the diagnosis is
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 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.