troubleshooting Question

SQL Server - Query Improvements for Uniqueidentifier tables

Avatar of AJS_Developer
AJS_Developer asked on
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008
7 Comments3 Solutions507 ViewsLast Modified:
Hi There,

I have a table which has a Guid primary key. The table contains around 400,000 rows, and the expectation is that it will increase up into the low millions, depending on external factors.

The table has around 90 columns, two of which contain data i want to query by.

Basically, my query looks like the following:

Select * from table1
where col1 = @value or col2 = @value

At the moment, it takes around 35 seconds to retrieve all data (400,000 records), and around 1 second to for the above query to run using the temp variable @value (roughly 20,000 records)

What methods can i implement to improve the query performance? I currently have a nonclustered index on the primary key - should another index be added on col1 / col2?

Any ideas are appreciated. I can envision a query like this one day returning 400,000 records, and i want it to be as quick as possible.

Cheers,
Ben.
ASKER CERTIFIED SOLUTION
dwkor

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 7 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 3 Answers and 7 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