Using native compilation

In this recipe, we will see how to instruct the database to compile our stored procedures in native form—rather than interpreted—to speed up the execution time.

Getting ready

To be sure that our database is not using native compilation by default, we can execute the following command from a SQL*Plus Session:

SHOW PARAMETER PLSQL_CODE_TYPE

If the result is NATIVE, we can execute the following statement to return to the original default value:

ALTER SYSTEM SET PLSQL_CODE_TYPE = INTERPRETED;

How to do it...

The following steps will demonstrate how to use native compilation:

  1. Connect to the SH schema:
    CONNECT sh@TESTDB/sh
    
  2. Create the function C_N_K, which calculates the number of k-combinations in a set of n elements:
    CREATE OR ...

Get Oracle Database 11gR2 Performance Tuning Cookbook 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.