Subject | Index on dates seems to do nothing |
---|---|
Author | Mark Patterson |
Post date | 2002-08-08T23:58Z |
Hi,
We have a large table, currently >400,000 records of 34 fields. Many of our
queries involve date ranges, e.g. report on all the work for first week in july:
SELECT * FROM SAWMEMBERSARCHIVED
WHERE START_TIME >= '7/1/2002' AND START_TIME < '7/6/2002'
It returns 1283 records. I ran it a few times with and without an index.
I created the index with this simple statement:
CREATE INDEX SMAJOB ON SAWMEMBERSARCHIVED (START_TIME)
Typical time without index: 4 secs
Typical time with index: 4 secs.
I had earlier been encouraged by the effects of an index on a string field,
using this query which returns 1510 records:
SELECT * FROM SAWMEMBERSARCHIVED
WHERE JOB_NUMBER = '0595-02'
Typical time without index: 4.2 secs
Typical time with index: 0.07 secs.
Is there a way to get the date index to have a similar effect? Or do indexes
work like hash tables? I imagine them to be like a sorted list.
Regards,
Mark Patterson
We have a large table, currently >400,000 records of 34 fields. Many of our
queries involve date ranges, e.g. report on all the work for first week in july:
SELECT * FROM SAWMEMBERSARCHIVED
WHERE START_TIME >= '7/1/2002' AND START_TIME < '7/6/2002'
It returns 1283 records. I ran it a few times with and without an index.
I created the index with this simple statement:
CREATE INDEX SMAJOB ON SAWMEMBERSARCHIVED (START_TIME)
Typical time without index: 4 secs
Typical time with index: 4 secs.
I had earlier been encouraged by the effects of an index on a string field,
using this query which returns 1510 records:
SELECT * FROM SAWMEMBERSARCHIVED
WHERE JOB_NUMBER = '0595-02'
Typical time without index: 4.2 secs
Typical time with index: 0.07 secs.
Is there a way to get the date index to have a similar effect? Or do indexes
work like hash tables? I imagine them to be like a sorted list.
Regards,
Mark Patterson