473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Index on date-fields with NULL values

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
2 22885
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: vnl | last post by:
I'm trying to run a SQL query but can't find any records when trying to select a certain date. Here's the sql: SELECT field 1, field2, date_and_time, FROM table1 WHERE date_and_time =...
8
by: David McDivitt | last post by:
I need to set tabs on java generated pages. Pages have four sections: header, sidebar, body, and footer. The sidebar and body change dynamically. The tab key must go to anchors, fields, and buttons...
4
by: ianv2 | last post by:
Hi Is the following possible using Javascript ? I would like a page to redirect to another page if the page expiry has passed. E.G. If my questionnaireform.html page had an expiry date...
5
by: Pedro Alves | last post by:
Hi. I'm having some trouble on the use of indexes. The querys below are exactly the same but refer to different months. One case uses indexes, the other doesn't. Is there anything I can do?...
3
by: Patrick Hatcher | last post by:
I have a timestamp field where I find I'm doing a lot of searching by date (YYYY-MM-DD) or using this field as a match to another table that has a date format. I wanted to create an index on the ...
1
by: William Bradley | last post by:
In a database I have a table that amongst other cells has a "current date" cell, and "expired date" cell and an "Index Number" cell. The "index number" cell contains code that converts the...
2
by: Thomas F.O'Connell | last post by:
I'm interested to know a little bit more about the postgres implementation of indexes. I'm specifically wondering what it means in the output of EXPLAIN when a filter is applied. I'm trying to...
5
by: Miquel van Smoorenburg | last post by:
I have a database with a btree index on the 'removed' field, which is of type 'date'. However it isn't being used: techdb2=> explain select * from lines where removed > CURRENT_DATE; QUERY PLAN...
6
by: db2admin | last post by:
hi, i have query doing tablescan instead index scan. i would explain situation in more detail. table has MDC on one column and three more regular indexes. now, one of the index which has three...
1
by: Steffen Stellwag | last post by:
Truely is often better to scan a table in full passing by an index , but if you can force the optimizer to use an index via a hint for testing and comparing the results. But the index in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.