SQL Index Optimization method

Source: Internet
Author: User

SELECT TOP 50
ROW_NUMBER() OVER(ORDER BY ResumeCreateTime DESC) as [RowID]
,[TopDegree]
,[DegreeRankID]
,[UserResume].[UserResumeID]
,[UserResume].[UserID]
,[ResumeName]
,[BirthDate]
,[WorkStartedDate]
,[SalaryNeeded]
,[BufferTimeSpanID]
,[ResumeCreateTime]
FROM [dbo].[UserResume] INNER JOIN [dbo].[WorkExperience] ON [WorkExperience].[UserResumeID] = [UserResume].[UserResumeID]
WHERE
(CONTAINS([WorkExperience].[WorkSummary],'经理') OR CONTAINS([UserResume].[ResumeName],'简历'))

First execution: No indexes were established.

Execution effect:

Table ' worktable '. Scan count 0, logical read 0 times

Table ' Userresume '. Scan count 1, logical read 18,524 times

Table ' Workexperience '. Scan count 1, logical read 8,679 times

(1 rows affected)

SQL Server Execution Time:

CPU time = 2152 milliseconds, elapsed time = 3126 milliseconds.

Second execution:

View Execution Plan workexperience table is a table scan, establishing Ix_workexperience index (on ID column and the ID column of join reference).

Effect after adjustment:

Table ' Workexperience '. Scan count 1, logical read 1071 times

Table ' Userresume '. Scan count 1, logical read 18,524 times

(1 rows affected)

SQL Server Execution Time:

CPU time = 1638 milliseconds, elapsed time = 2045 milliseconds.

Third execution:

View execution plan, Userresume table is table scan, establish Ix_userresume index.

Effect after adjustment:

Table ' Workexperience '. Scan Count 11, logical read 48 times

Table ' Userresume '. Scan count 1, logical read 3,095 times

(1 rows affected)

SQL Server Execution Time:

CPU time = 1248 milliseconds, elapsed time = 1568 milliseconds.

Fourth time execution:

View the execution plan, after the Ix_userresume index scan, resulting in a reordering of the createtime columns, adjusting the createtime location and collation of the Ix_userresume index.

Effect after adjustment:

(50 rows affected)

Table ' Workexperience '. Scan Count 11, logical read 48 times

Table ' Userresume '. Scan count 1, logical read 3 times

(1 rows affected)

SQL Server Execution Time:

CPU time = 15 milliseconds, elapsed time = 404 milliseconds.

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.