troubleshooting Question

sql 2008 primary key, index performance

Avatar of MikeBroderick
MikeBroderick asked on
Microsoft SQL Server 2008Microsoft SQL Server
16 Comments5 Solutions59 ViewsLast Modified:
When I build an index that looks exactly like my primary key, select performance increases dramatically. Why is this?

The table has 5 primary key fields, A B C D and LineNum. I want all the records for a given A, B, C and D. My select includes WHERE A= aaa AND B=bbb AND C=ccc AND D=ddd, and has ORDER BY A, B, C, D. The table has 4.1 million records in it. A fill takes about 25 seconds. When I create an index that also has A B C D and LineNum, the fill takes about 2 seconds. An index with just A B C and D takes about 2 seconds. When I delete the index, the query time goes back to about 25 seconds.

Any ideas why adding an index that looks like the primary key speeds up the query?
ASKER CERTIFIED SOLUTION
Aneesh
Database Consultant
Join our community to see this answer!
Unlock 5 Answers and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 5 Answers and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros