Select ‘X’ faster then Select 1

What somebody at Oracle Belgium told me once 10 years ago, I retested it on Oracle 10R2.
A Select ‘X’ is faster then a Select 1.
Stop dreaming because it’s only slightly faster.
see here the tests I did

SET time ON
SET timing ON
 
declare
 v_n number;
 v_c varchar2(1);
begin
FOR i IN 1..1000000 loop
 SELECT 'X' INTO v_c FROM dual;
end loop;
end;
/
 
declare
 v_n number;
 v_c varchar2(1);
begin
FOR i IN 1..1000000 loop
 SELECT 1 INTO v_n FROM dual;
end loop;
end;
/

And see here the results:
TRY    SELECT ‘X’       SELECT 1
___    __________     _________
1          27s00             27s03
2          27s00             27s02
3          26s09             27s02
4          27s00             27s03
5          27s00             27s04
6          53s08             55s00    (case 6 is with 2M itterations)

Leave a reply

You must be logged in to post a comment.