1. For comparison of date size, the date format passed to XML must conform to 'yyyy-MM-dd', so that it can be indexed, such as: 'yyyy' is changed to 'yyyy-MM-dd', 'yyyy-MM' is changed to 'yyyy-MM-dd' [in this way, MYSQL will convert it to date type] 2. In the conditional statement, whether it is equal to, greater than or less than, do not use functions, expressions or mathematical operations in the conditional query field on the left side of 3. Try to adjust the order of fields in the 4. Ensure that the query results before and after SQL optimization are consistent 5. When querying, write the 6. Do not use 7. Try to decompose complex queries and perform table joins at the application level instead of SQL level. 8. Create indexes on columns involved in 9. Avoid 10. Avoid using 11. Avoid using 12. 13. 14. Avoid expression operations on fields 15. Avoid performing function operations on fields 16. 17. If it is a numeric field, try to design it as a numeric field. Don't bury the hatch for the colleagues who will maintain it later just for the sake of convenience or laziness. 18. All fields in the table are designed to be 19. When the number of returned records is fixed, use the 20. For enumeration type fields (i.e. fields with fixed enumerated values), it is recommended to use 21. The field storing the IP address is designed to be of 22. Avoid using 23. For statistical queries [such as querying the total amount of data for several consecutive months, or querying year-on-year or month-on-month changes, etc.], you can improve the query speed by performing regular queries and adding statistics to the statistical table. Summarize The above is the Mysql slow query optimization method and optimization principles introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Usage and best practice guide for watch in Vue3
>>: Detailed explanation of screen command usage in Linux
Interviewer: Have you read the source code of Vue...
nbsp   no-break space = non-breaking spa...
Introduction to Angular Angular is an open source...
First of all, let me talk to you about my daily l...
The interviewer will sometimes ask you, tell me h...
The file name of the dynamic library file under L...
Table of contents Features of etcd There are thre...
1. Introduction In the past, if you wanted to sta...
Recently, the following effects need to be achiev...
After installing Redis on Linux, use Java to conn...
Clicking to switch pictures is very common in lif...
Preface When using RabbitMQ, if there is no traff...
This article shares a sharing sidebar implemented...
1. Four startup methods: 1.mysqld Start mysql ser...
Table of contents Preface Option 1: Option 2: Opt...