First, performance detection and bottleneck analysis
1 common commands for performance detection
Show status
Display status information, reference: Mysql Show status Command detailed
Show Processlist
View current SQL execution, including
1.mysql Remote Connection command can import exported data remotely
Mysqldump--default-character-set=gb2312-h255.255.000.00-uroot-pxxxxxx Mydatabase>d:\data.sql
Export the specified database to an external SQL file!
Restore
Precautions:As long as the following 4 points, 2 MySQL can be installed simultaneously to a machine PS: Can extrapolate, a machine as long as you load enough, want to install a few can. Here are 2 examples:My test server is configured to 2 6-core
as the name implies, the slow query log is a long execution of query, that is, we often say slowquery, by setting--log-slow-queries[=file_name] to open the function and set the record location and file name. The slow query log is a simple text
The recent local debugging site when individual programs such as PHPCMS has been this problem, the speed is unusually slow, and occasionally found the following article, just reminded me, the original question like this ...
When I recently
The online business uses the ORM framework, and discovers a slow query SQL that has been sorted two times in the same field, resulting in filesort. The ORM Framework has its own table structure as follows:
CREATE TABLE ' Unopen ' ( ' Corp '
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 slow query log feature is not turned on by default, and it records a value that executes longer than the parameter Long_query_time (default is 10) and the number of rows accessed exceeds the SQL statement that the parameter
Slow queries need to be optimized for normal workYou have to use Percona-tookit's pt-query-digest to analyze slow logs.Percona-tookit:Https://www.percona.com/doc/percona-toolkit/3.0/index.htmlHow to use:#pt-query-digest Slow log filesThe summary of
Modifying a configuration fileShow_query_log = OFF whether to turn on slow log query long_query_time = 2 time limit, over time, record slow_query_log_file =/usr/slow.log log file _queries_not_using_indexs = OFF to open the log for searches that do
Command: Show Processlist;If it is the root account, you can see the current connection for all users. If you are a normal account, you can only see the connection you are occupying.Show Processlist; only the first 100 are listed, please use show
One: Query the status of slow log, as shown in the sample code, slow log is already open.Mysql>Show variables like '%slow%';+---------------------+------------------------------------------+|Variable_name|Value|+---------------------+----------------
How do I turn on the slow query log?Added in MySQL config file my.cnfLog-slow-queries=/var/lib/mysql/slowquery.log (Specify the log file location, can be empty, the system will give a default file Host_name-slow.log)long_query_time=2 (record over
1 in MySQL, the default is not to turn on the slow query log function, we can use show variables like '%slow% ' to see. The results are as follows:650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/26/EA/wKiom1NuKfvDr8nqAAFYiGubJfQ397.jpg
This article mainly introduces how to handle the faults caused by slow MySQL queries. slow queries are a convenient feature that we often use in mysql, slow query is very useful for queries with tracing problems. For more information about how to
Mysqlsla is a MySQL Log Analysis Tool launched by hackmysql.com. It can analyze mysql slow query logs and analyze slow queries. It can analyze slow query language for databases.
Mysqlsla is a MySQL Log Analysis Tool launched by hackmysql.com. It can
MySQL5.6 how to optimize slow query SQL statements -- Introduction to slow logs
Recently, a development team complained that the mysql cluster included in our platform was not good and always reported the "heartbeat Error" of mysql and analyzed the
MySQL tuning bitsCN.com
Optimization and optimization:
1. database design and planning-it will be difficult to fix it later, estimate the data volume and what storage engine to use
2. data application-how to retrieve data and optimize SQL
Use pt-query-digest to find the SQL statement that is not suitable, pt-query-digestsql
Overview of pt-query-digest1.
Indexes can be executed more quickly, but there must be unreasonable indexes. If you want to find those indexes that are not very
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.