This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10842|Reply: 0

[Communication] Optimize SQL queries for speed

[Copy link]
Posted on 1/27/2015 8:16:51 PM | | |
After the data in the SQL SERVER table reaches a certain amount (more than one million), the speed of executing queries and updating statements will become quite slow, and I often encounter such problems during this period.
One way to increase speed is to use indexes. Specifically, there are two ways, which are explained as follows:
The first method: Modify the WHERE statement of the query or update statement, and try to include the columns included in the index in the WHERE statement。 In particular, including columns in the aggregated index is helpful for faster execution.
The second method: Establish an appropriate index based on the query or update statement。 This requires using the index optimization wizard provided by SQL SERVER Query Analyzer, which analyzes SQL statements to arrive at the appropriate index.
It should also be said that when solving such problems, it is necessary to consider joint and collateral issues. If a stored procedure is slow to execute, in addition to optimizing the statements in the stored procedure, it is also necessary to consider whether the process triggered by the statement in the stored procedure also needs to be optimized, such as whether the statements in the corresponding triggers triggered by updating or inserting table statements need to be optimized.
The third method: stage the data in the table to the temporary table before processing the data.This approach can greatly improve the speed of execution, but it does not solve the concurrency problem. The statement is as follows:
SELECT * INTO #临时表 FROM the official table
The fourth method: use the fast enter-only cursor.If no modification is involved, you can use the Quick Enter only cursor instead of the normal cursor to increase the speed.

Find the optimization points and optimize:
1. Using Execution Plans: Query Analyzer menu "Query -> Display Estimated Execution Plans"
2. In the storage process, find the statement that needs to be optimized
3. Create an index using the Index Optimization Wizard: Log in to the Query Analyzer with SA and go to the menu "Query -> Index Optimization Wizard"





Previous:How to improve SQL Server query speed
Next:SQLSERVER server configuration
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com