SQL optimization

xiaoxiao2021-03-06  81

Last year, I made a information website. Since the amount of data was not very large, the SQL statement wrote very casually, did not do it, the database did not do anything, because the amount of data was small, so I couldn't see it. What, but later, as the database increases, the display is getting slower and slower. When the data reaches more than 3 million, there is often an incorrect error that I have seen, I thought it was a problem with the performance of the database. So the database is optimized (tune the minimum memory occupation, and maximum memory), there are some effects, although the access is slow, but at least not. When the data reached more than 4 million, the error that could not be accessed, so I decided to optimize and establish an index for SQL statements and programs. The first is to establish an index because I have been experimenting, I found that the slow place is mainly because of the sort, so I decided to build a clustered index for the sort field updateTime. Note: because UpdateTime, the information in one day is the same, so suitable for establishing Cluster index. After establishing a clustered index, the speed has a certain increase, but it is still a bit slow. Then start to modify the program again, first of all, remove unwanted queries, sort, then use UpdateTime as needed, this speed is increased. Finally, in the SQL query, do not use *, but use the specific field instead of it, this speed can reach the basic requirements. Machine configuration: RAM: 256 CPU: 2.4 (1) Harddisk: SCSI 36G Dell SQL Server2000 or more is just some of my personal opinions, please do your master. Because I just learned the SQL language.

转载请注明原文地址:https://www.9cbs.com/read-94479.html

New Post(0)