Documente Academic
Documente Profesional
Documente Cultură
Native compilation
- Sagar T.
Compilation
When PL/SQL is loaded into the server it is compiled to byte code before execution. Two methods :
Interpreted Native
Interpreted Compilation
Default compilation method Interpreted at run time With interpreted compilation, the PL/SQL statements in a PL/SQL program unit are compiled into an intermediate form, machinereadable code, which is stored in the database dictionary and interpreted at run time.
PVM
The PVM is implemented as a set of subroutines in the Oracle Executable, and scans the M-code at run-time. The scanning detects each successive OPCODE and its OPERANDS, then calls the subroutine that implements this OPCODE with actual arguments. This run-time scanning of M-code takes some resources, and this (only this) can be improved using PL/SQL NATIVE Compilation.
Native Compilation
Compiles into native code Stored in the SYSTEM tablespace Because the native code does not have to be interpreted at run time, it runs faster
Native code
In the native mode, a platform-specific dynamically linkable library (DDL) (similar to .dll in Windows or .so in Unix) is produced. This platform-specific DLL, at run time, calls exactly the same PVM subroutines with same arguments as would have been called by scanning the M-Code. In short, the performance improvement is due to the fact that the scanning effort has been moved from run time (when in interpreted mode) to compile time (when in native mode).
Oracle 10g
Oracle 10g upgraded the native compilation feature by storing the compiled code in a database catalog. If the code is required, server used to load it from the catalog and not from the shared libraries (Native DLLs).
Example
CREATE OR REPLACE CREATE OR REPLACE PROCEDURE PROCEDURE native_test(v_out OUT INTEGER ) interpreted_test(v_out AS OUT INTEGER ) AS BEGIN for i in 1 .. 5000000 loop BEGIN for i in 1 .. 5000000 loop v_out := i + i; end loop; v_out := i + i; END; end loop; / END; ALTER PROCEDURE native_test /
COMPILE PLSQL_CODE_TYPE = NATIVE
THANK YOU!