[Translation] SQL Server optimization tips

Source: Internet
Author: User

Q: I occasionally find that the SQL Server built-in query optimizer is inefficient and the query plan is not optimized. How can I adjust the query plan?

A:
You can use the SQL Server optimization prompt to overwrite the query optimizer. Optimization tips can be divided into five categories:
Table prompt: used to force index selection
Query prompt: Used to affect group by and UNION functions
Lock prompt: Used to help avoid unwanted locks
View tip: used to specify indexes in the index View
Other Tips: various tips

In general, try to reduce the number of prompts. This is because the query optimizer is much more sensible in most cases, and the query plan it generates is usually optimal. If the specified prompt is incorrect or not the best, it will generate a query plan according to the error method, which continuously affects the performance.

If you think you may need to use a prompt to optimize your query, please first confirm that you have done the following steps that may be the cause of the problem:
1. update statistics of related tables
2. If the problem query is in the stored procedure, recompile the stored procedure and run it again to check whether the situation has been improved.
3. Check the search parameters to make sure they are searchable and optimized.
4. Check the current index and make changes if necessary.

If you have performed the preceding operations and the query still cannot be executed as expected, you need to consider using appropriate optimization tips.

Another problem with the usage prompt is that the prompt may only work in a specific scenario. If the scenario changes, the prompt may not be appropriate.

For more information, see http://msdn.microsoft.com/en-us/library/ms187713.aspx.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.