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
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.