Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Which is faster? <> or Between
I think that it will matter more if you have indexes and such on the table
in question than on the method that you use to do the compare. I ran the
following test (on 8.1.7 via remote sqlnet hookup) and for the 10,000
iterations the difference was less than 20 - with between being slower.
l_date DATE;
l_first DATE;
l_end DATE;
start_time binary_integer;
end_time binary_integer;
BEGIN
l_date := SYSDATE;
l_first := To_Date( '01-JAN-2003', 'dd-mon-yyyy' ); l_end := To_Date( '01-MAR-2003', 'dd-mon-yyyy' );
start_time := Dbms_Utility.get_time;
FOR l_looper in 1..10000
loop
SELECT 1
INTO answer FROM dual WHERE 1 = 1 OR ( l_date >= l_first AND l_Date <= l_end );
Dbms_Output.put( '">= <=" elapsed=' ); Dbms_Output.put_line( end_time - start_time );
start_time := Dbms_Utility.get_time;
FOR l_looper in 1..10000
loop
SELECT 1
INTO answer FROM dual WHERE 1 = 1 OR ( l_date between l_first AND l_end );
Dbms_Output.put( '"between" elapsed=' ); Dbms_Output.put_line( end_time - start_time );
END;
![]() |
![]() |