SQL Server Performance Optimization

Source: Internet
Author: User

Source code files

1, what is a performance issue?

If the existing resources do not reach the maximum throughput, the system cannot meet the reasonable expected performance, then it can be defined as a performance problem. Performance metrics include: response time, throughput, scalability.

2, a preliminary study of optimization

2.1 Optimization theory

2 performance issues are commonly encountered:

1), a function is slow, or suddenly slow, such as a stored procedure, query and so on.

2), the whole system is very slow.

In the first case, the object is relatively clear, so it is easier to handle. In most cases, only the implementation plan needs to be studied to solve most of the problems. By changing the query, adjusting the table structure (index, etc.). Can play a significant effect.

In the second case, the object is ambiguous and the bottleneck needs to be positioned first. You can perform a summary analysis by using performance counters, SQL Profiler/sql Trace, extendedevents (SQL Server 2008). Then locate the bottleneck.

2.2 Defining the problem

2.2.2 By classifying performance data. After the processing is completed, the deep analysis and summary are summarized.

1), analyze the wait at the database instance level. Use performance counters, SQL Profiler for monitoring.

6), optimize index/query: A, improve the code: use a CTE instead of a cursor query.

Key words:
Sarg:sarg (searchable arguments operation, because it usually refers to a particular match, a worthy range of matches, or a connection of more than two conditions.

1, wildcard% opening of the string causes the index to be unusable. Name like '% Zhang ', does not belong to Sarg.

2,or will cause a full table scan. Name= ' Zhang San ' or price >5000 is not in accordance with SARG.

3,in equivalent to or

4, it is usually more efficient to use union than to use or.

5, be sure to avoid the Select useless field.

6, by paging, etc.

Sarg:http://baike.baidu.com/link?url=7zxaydrpukcbltpbt45lmprjymf5ls89cdodskxa08xbt3sppuivuf_ 0caqevucbzupjqkqtxpmseekg7kgf3q

SQL Server Performance Optimization

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.