Home » RDBMS Server » Server Administration » Does trunc slow down performance
Does trunc slow down performance [message #371473] Wed, 25 October 2000 18:42 Go to next message
CC
Messages: 2
Registered: October 2000
Junior Member
If I use trunc in the where clause of a date column does it slow down the query (assuming that the column is an indexed column).

e.g.

select name
from emp
where trunc(hiredate) = '10-OCT-00';
Re: Does trunc slow down performance [message #371480 is a reply to message #371473] Thu, 26 October 2000 12:59 Go to previous messageGo to next message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
No, the trunc function is one of the few functions which can still make use of an index on that column. to_char, || etc all knock out the index (unless you are using a function based index like "CREATE INDEX Idx_1 ON Emp(Sal*1.1);" which is a new 8i feature)
Re: Does trunc slow down performance [message #371481 is a reply to message #371473] Fri, 27 October 2000 07:59 Go to previous messageGo to next message
Marcus Fernando
Messages: 34
Registered: September 2000
Member
I tried to create an index like this and Oracle gave me the error msg ORA-00439 - Feature not enabled. Function-Based Indexes.
How can i do to enable that feature.
Is is posible to create an unike index with UPPER(Field) ?
Re: Does trunc slow down performance [message #371486 is a reply to message #371473] Fri, 27 October 2000 15:01 Go to previous messageGo to next message
Hari
Messages: 59
Registered: August 2000
Member
select name
from emp
where trunc(hiredate) = '10-OCT-00';
use this WAY
select name from emp
where hiredate between trunc('10-0ct-00') and trunc('10-oct-00') + 0.99999;

so that the index is used and u get all therecords for that day ... hope this helps..
Re: Does trunc slow down performance [message #371487 is a reply to message #371473] Fri, 27 October 2000 15:02 Go to previous message
Hari
Messages: 59
Registered: August 2000
Member
select name
from emp
where trunc(hiredate) = '10-OCT-00';
use this WAY
select name from emp
where hiredate between trunc('10-oct-00') and trunc('10-oct-00') + 0.99999;

so that the index is used and u get all therecords for that day ... hope this helps..
Previous Topic: Package - REF CURSORS.. with parameters procedures
Next Topic: Find all row from one table exists maximum in other
Goto Forum:
  


Current Time: Sat Apr 27 05:31:01 CDT 2024