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
To put it simply, MySQL worm replication is to co...
Docker queries or obtains images in a private reg...
1. Dynamically create objects There are two ways ...
This article shares the installation and configur...
WeChat Mini Program Component Design Specificatio...
Preface Recently, part of the company's busin...
bgcolor="text color" background="ba...
Table of contents Semaphore Nginx hot deployment ...
Recorded the download and installation tutorial o...
It’s great to use CSS to realize various graphics...
MySQL query by year, month, week, day group 1. Qu...
Table of contents 1. Insert the queried results 2...
Use CSS3 to achieve cool radar scanning pictures:...
Table of contents 1. Drag effect example 2. CSS I...
1. Install Docker First open the Linux environmen...