If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Is using index on the date-column beneficial?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-06-11, 16:47
Plural Plural is offline
Registered User
 
Join Date: Oct 2011
Posts: 12
Is using index on the date-column beneficial?

I have a few tables with date columns such astreatmentDate and scheduleDate.
Assume these tables will be used by receptionists in a clinic.
Although it cannot be transparent to them 100%...when they query for a specific date, will using an index be beneficial?

For example, one of my views:
Code:
CREATE VIEW DoctorSchedule_A AS
SELECT d.*, s.scheduleDate, s.clinic
FROM Doctor d, Schedule s
WHERE d.doctorID=s.doctorID;
Nurse querying for a specific/random date:
Code:
SELECT *
FROM DoctorSchedule_A
WHERE scheduleDate='01-JAN-1970';

SELECT *
FROM DoctorSchedule_A
WHERE scheduleDate BETWEEN '01-JAN-1970' AND '05-JAN-1970';
Reply With Quote
  #2 (permalink)  
Old 12-06-11, 18:03
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,415
>will using an index be beneficial?
It depends upon what data exists & what data being returned

With Oracle characters between single quote marks are STRINGS!
'This is a string, 2009-12-31, not a date'
When a DATE datatype is desired, then use TO_DATE() function.

what date is '07-08-09'?
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
  #3 (permalink)  
Old 12-06-11, 20:34
Plural Plural is offline
Registered User
 
Join Date: Oct 2011
Posts: 12
So...those were created using the DATE datatype...do I still need to use the TO_DATE('07-08-2009','MON-DD-YYYY')?
Reply With Quote
  #4 (permalink)  
Old 12-06-11, 20:39
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,415
>do I still need to use the TO_DATE('07-08-2009','MON-DD-YYYY')?
yes, it is poor & sloppy programming to depend upon implicit datatype conversion
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
  #5 (permalink)  
Old 12-07-11, 08:35
beilstwh beilstwh is offline
Lead Application Develope
 
Join Date: Jun 2004
Location: Liverpool, NY USA
Posts: 2,222
to answer your original question, an index on the date columns if you query using the dates will be beneficial.
__________________
Bill
You do not need a parachute to skydive. You only need a parachute to skydive twice.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On