Simple MySQL optimization tool-slow query and mysql optimization tool
Slow Query
First, enabling slow queries is a prerequisite regardless of the optimization. The slow query Mechanism records slow query statements (events) to provide optimization objectives for DB maintenance personnel.
Check whether slow query is enabled
Passshow variables like 'slow_query_log'
This statement can be used to find the slow query status (On/Off ).
Enable slow Query
MySQL version used in this article: MariaDB-10.1.19. Note that there are differences between MySQL versions.
Add the following under [mysqld:
[Mysqld] port = 3306slow-query-log = 1 # slow query: confirm to enable slow-query-log-file = "D:/xampp/mysql/log/mysql-slow.log" # slow query: log File and path long_query_time = 5 # Slow query: Specify the statements that have not been completed for more than 5s, and execute slow statements.
Optimization steps
Observe the log and lock the target statement to be optimized. Pay attention to SQL settings, such:SQL_NO_CACHE
.
Focus on complex statement writing. Complex statements have a high degree of freedom. In addition, the special nature of SQL syntax leads to complicated statements with the same function in different writing methods, which may have a different efficiency.
Although we have principles in various occasions, we can make efficient localization Optimization for specific application scenarios.
Statements that cannot be optimized. When we use the above two methods and more optimization methods that are not mentioned in this article, we may still face optimization failures. If the business layer is not corrected, the data layer is indeed powerless.
Conclusion
When the game cannot be optimized, I can't help but think of my favorite game design industry.
If you know something about it, you will find that there are actually a lot of excellent designs in game design, but most of them are embarrassed by the local technical skills at that time, however, it is impossible to achieve a colorful game design.
I also remember my friend who made the UI spoke to me last year: I was afraid that I would design it very cool or humanistic, but the front-end could not implement that design.