By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,321 Members | 1,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,321 IT Pros & Developers. It's quick & easy.

Index on date-fields with NULL values

P: n/a
Ik have created an index on a date field.
99% of all data in the table has a filled in date. 1 % is NULL
When I do a select with clause ... WHERE ADATE IS NULL,
Oracle does not use the index.

Is this correct? or How can I force Oracle to use the index.

Kind reagrds,
Aad.

PS: I am using Oracle 8.1.7 and 9.2
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Aad Aldus" <a.*****@modality.nl> wrote in message news:<3f***********************@news.xs4all.nl>...
Ik have created an index on a date field.
99% of all data in the table has a filled in date. 1 % is NULL
When I do a select with clause ... WHERE ADATE IS NULL,
Oracle does not use the index.

Is this correct? or How can I force Oracle to use the index.

Kind reagrds,
Aad.

PS: I am using Oracle 8.1.7 and 9.2


This is correct. If all of the columns of an index are null that
record is not included in the index.
NULL means *nothing*.
Hence IS NULL will NEVER use an index.

You cannot force Oracle to use the index (this is documented behavior,
and has always worked this way) other than
- use a function based index (Oracle EE edition only, and in that case
-especially if only 1 percent is null- you are killing an insect with
a sledgehammer)
- use a dummy date for the null values

Regards

Sybrand Bakker
Senior Oracle DBA
Jul 19 '05 #2

P: n/a
Aad Aldus wrote:
Ik have created an index on a date field.
99% of all data in the table has a filled in date. 1 % is NULL
When I do a select with clause ... WHERE ADATE IS NULL,
Oracle does not use the index.

Is this correct? or How can I force Oracle to use the index.

Kind reagrds,
Aad.

PS: I am using Oracle 8.1.7 and 9.2

Given that 99% of the table-data is returned by the query a Full table
scan is actually faster than using an index.


Michael Willer
Oracle/J2EE architect
Cyber Com Consulting a/s

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.