SQL Server database optimization analysis (graphic analysis) _mssql

Source: Internet
Author: User

The following are shown in the Illustrated form:

First, SQL Profiler

Event class Stored procedures\rpc:completed tsql\sql:batchcompleted

Event-critical Fields Eventsequence, EventClass, SPID, DatabaseName, Error, StartTime, TextData, HostName, ClientProcessID, ApplicationName, CPU, reads, writes, Duration, rowcounts

1, tracking slow SQL

2. Tracking SQL Execution Errors

3, debugging found in the SQL with special characters as a filter criteria  

4. T-SQL query trace table

A, set crawl time segment

b, keep the file and query the file with the following statement

Copy Code code as follows:

SELECT Eventsequence,spid,requestid,databaseid,databasename, Loginname,starttime,endtime, TextData,Error, Duration /1000 as Duration,reads,cpu,writes,rowcounts, hostname,clientprocessid,applicationname into Bak.dbo.traceFROM:: fn_ Trace_gettable (' C:\trace\DB50 20150623.trc ', default)

Second, table storage structure

1, page structure

2 District Structure

3 File Storage

4, base table

5. Heap Table

6. Clustered index

7. General Index

Third, index optimization

1, high selectivity high uniqueness of the field put the front

2. Overwrite index Select, where, and by-by fields are in the index or include this will go to the index

3, the control index quantity, narrow index This graph index function is not big

4. Improve SQL statements

A, SQL as simple as possible

b, parameterized sarg definition column name operator < constant or variable > name= ' John ' and Price >5000

C, Srag name like '% ' name= ' John ' and price >5000 not,!=, <>,!<,!>, not EXISTS, not in, not-like four, execution plan

--Display statistics

Copy Code code as follows:

Set STATISTICS IO on set STATISTICS time on the SELECT * FROM dbo. Freezeusermoney

Open the executive focus and look at a few places below.

The above is for optimizing SQL Server database All content, hope everybody can like.

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.