I stole @FlorinGhita's code and changed it to:
declare
t number;
d date;
begin
t := dbms_utility.get_time();
for k in 1..10000 loop
select sysdate into d from dual;
end loop;
dbms_output.put_line(dbms_utility.get_time() - t);
t := dbms_utility.get_time();
for k in 1..10000 loop
d := SYSDATE;
end loop;
dbms_output.put_line(dbms_utility.get_time() - t);
end;
because I wanted to contrast the amount of time required to do the SELECT with the amount of time required to perform the direct assignment.
The results of five runs of the above were
SELECT Assignment
73 6
84 6
74 6
74 6
74 5
Next, my thought was that perhaps there was overhead associated with having the SELECT statement first - so I changed it around so that the assignment loop was done first followed by the SELECT loop:
declare
t number;
d date;
begin
t := dbms_utility.get_time();
for k in 1..10000 loop
d := SYSDATE;
end loop;
dbms_output.put_line(dbms_utility.get_time() - t);
t := dbms_utility.get_time();
for k in 1..10000 loop
select sysdate into d from dual;
end loop;
dbms_output.put_line(dbms_utility.get_time() - t);
end;
Five runs of the above gave:
Assignment SELECT
5 78
6 75
7 72
6 75
6 86
If I'm reading the above correctly it shows that performing a SELECT...FROM DUAL
takes more than 10 times LONGER than making a direct assignment.
Takeaway: don't use SELECT xxxxx INTO zzz FROM DUAL
. Use zzz := xxxxx
instead.
Timings above were generated by Oracle 11.1
Hope this helps.