troubleshooting Question

BETWEEN in a SELECT is slow.

Avatar of dnadeveloper
dnadeveloperFlag for United States of America asked on
Microsoft SQL ServerSQL
8 Comments1 Solution263 ViewsLast Modified:
I’m using SQL Server 2000 and a BETWEEN in the WHERE clause.
My basic query is:
SELECT * FROM mytable WHERE 3507184416 between RangeLow AND RangeHigh

There is a clustered index on RangeLow and a nonclustered index on RangeHigh.
Both fields are BigInt and there are about 7 million records in the table.
A query like the following will complete immediately. .
SELECT MAX(RangeLow) from  mytable where RangeLow <= 3507184416
If I use between it takes about 4.5 minutes.
Anyone know what I should be doing for this to work properly?

TIA,
Chris
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
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 1 Answer and 8 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