Search This Blog

Friday, December 23, 2011

SQL Performance

DECLARE
TYPE rc IS REF CURSOR;
l_rc rc;
l_dummy all_objects.object_name%TYPE;
l_start number DEFAULT dbms_utility.get_time;
BEGIN
FOR i IN 1 .. 1000
LOOP
OPEN l_rc FOR
'select object_name
from all_objects
where object_id = ' || i;
FETCH l_rc INTO l_dummy;
CLOSE l_rc;
dbms_output.put_line(l_dummy);
END LOOP;
dbms_output.put_line(ROUND((dbms_utility.get_time-l_start)/100, 2) ||' Seconds...' );
END;
/