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
1. What is deadlock? The official definition is a...
Simple application deployment 1. Directory struct...
Mysql5.5 dual machine hot standby Implementation ...
Table of contents 1.mysqldump Execution process: ...
This article example shares the specific code of ...
Table of contents Problem Description 1. Basic so...
Table of contents 1. Operate the database 1.1 Cre...
1. Replication Principle The master server writes...
The user organization has two Windows Server 2008...
CSS sets Overflow to hide the scroll bar while al...
Table of contents Add Configuration json configur...
Table of contents posgresql backup/restore mysql ...
1. Introduction Are you still leaving your websit...
Today I got familiar with the mouse zooming effect...
The optimization created by MySQL is to add index...