Directory
Slow query log
Slow Log analysis tool uses
General optimization Strategy
Slow query logMySQL's slow query log is a log record provided by MySQL, which is used to record a statement in MySQL that has a response time
Open binary log (binary log content: Change the operation of the database)In the/ETC/MYSQL/MY.CNFRemove the comment from the Log_bin line to open the following is the saved pathThe following expire_logs_days is how long, MySQL automatically deletes
1, configuration onLinux: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 time, default
Configure and use MySQL slow query logs ., Mysql query log
MySQL slow query log provides query information that exceeds the specified time threshold, and provides a major reference for performance optimization. It is a very practical function,The
This article mainly introduces Mysql log files and log types. This article describes the log file types, error logs, General query logs, slow query logs, binary logs, and so on, for more information, see
Log file type
MySQL has several different
1. The configuration is enabled.Linux: In the mysql configuration file my. add log-slow-queries =/var/lib/mysql/slowquery in cnf. log (specify the location where the log file is stored, which can be null, the system will give a default file
As the programmer may not write the best things, we only need to enable the mysql slow query log function to analyze the performance of each SQL statement. Let's take a look at it.
In MySQL, the definition time of a slow query is specified by the
The log file type MySQL has several different log files, which can help you find out what happened inside mysqld: errors in logging information types in log files when logging starts, runs, or stops mysqld. Query the Client Connection established by
In MySQL5.1 slow query logs, slow queries without indexes are the same as those with indexes. To prevent slow queries without indexes from being recorded in slow query logs, use -- log
In slow query logs of MySQL 5.1, slow queries without indexes
How to enable slow query in MySQL
1. The configuration is enabled.
Linux:
Add
Log-Slow-queries =/var/lib/MySQL/slowquery. Log (specify the location where the log file is stored, which can be empty and the system will give a default file
(1)
Reduce Database Access Static pages are possible Static parts of a dynamic page Some data can be generated as XML or saved as text files Use data caching technology, such as memcached (2)Optimization Detection Method 1. User Experience
When the -- log-slow-queries [= file_name] option is enabled, mysqld writes a log file containing all SQL statements whose execution time exceeds long_query_time seconds. Obtaining the initial lock time is not counted as the execution time.
If the
Mysqldumpslow:Died at/usr/local/mysql/bin/mysqldumpslow line 161, <> chunk 236.
Conclusion: The number of top jobs is too large, and mysqldumpslow cannot be traversed.
/Usr/local/mysql/bin/mysqldumpslow-s-t 15/root/db01-102-slow.log
1. Try removing
MySQL Log File Type
Introduction:
MySQL provides various types of log files that reflect different MySQL information and are necessary to understand them.
1. Error log (Error log)
The error log records all severe warnings and error messages during
Mysql database optimization summary and mysql database Summary
I. Common Database optimization operations
1. The table design must conform to the three paradigm.
2. Add an appropriate index, which has a great impact on the query speed. You must add
Basic operation of the service/etc/init.d/sendmail Start # Launch service/etc/init.d/sendmail Stop # Close Service/etc/init.d/sendmail Status # View the current status of the service/date/mysql/bin/mysqld_safe--user=mysql # start MySQL background
In MySQL, the definition time of the slow query is specified by the mysql built-in parameter variable long_query_time, its default value is 10 (in seconds), we can show variables like ' long_query_time '; Directive to view the information for this
# Redis Sample configuration file# Note Unit problem: When you need to set the memory size, you can use a common format like 1k, 5GB, 4M:## 1k => 1000 bytes# 1kb => 1024 bytes# 1m => 1000000 bytes# 1mb => 1024*1024 bytes# 1g => 1000000000 bytes# 1GB
At the same time, the amount of online access continues to increase for 1G memory server Obviously feel the difficulty of severe when even every day will panic or occasional server card This problem once bothered me for more than half a month MySQL
In web development, we often write some SQL statements, a bad SQL statement may make your entire program is very slow, more than 10 seconds, the average user will choose to close the page, how to optimize the SQL statements to run longer time SQL
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.