13-5. Optimizing Computationally Intensive Code
Problem
You have computationally intensive code that you want to optimize to decrease its running time.
Solution
Recompile the package, procedure, or function in native mode using the NATIVE
setting:
ALTER PACKAGE my_package COMPILE BODY PLSQL_CODE_TYPE=NATIVE REUSE SETTINGS;
ALTER PROCEDURE my_procedure COMPILE PLSQL_CODE_TYPE=NATIVE REUSE SETTINGS;
ALTER FUNCTION my_function COMPILE PLSQL_CODE_TYPE=NATIVE REUSE SETTINGS;
Here is an example of a computationally intensive procedure. It uses the factorial
function from Recipe 17-4.
CREATE OR REPLACE PROCEDURE factorial_test as
fact NUMBER;
BEGIN
FOR i IN 1..100 LOOP
fact := factorial(33);
END LOOP;
END factorial_test;
-- ...
Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.