Quick bullet points from reading the Transparent Performance Improvement: Real Native Compilation from the PL/SQL Enhancements in Oracle Database 11g white paper:
- The PL/SQL is an interpreted language but it is not just like other interpreted languages , e.g. BASIC, where the code is processed statement by statement at the run time. The PL/SQL code is compiled into machine code called M-Code with a target virtual machine called PL/SQL Virtual Machine (PVM), just like Java to Java Virtual Machine (JVM).
- The PVM is implemented as a set of subroutines in Oracle executables, 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 the M-Code takes some resources. This is where the PL/SQL native compilation will help with improvement.
- Compilations of both follow the same path:
- In the interpreted mode, the M-Code is produced.
- 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).
- Since exactly the same PVM subroutines are called with exactly the same arguments in both interpreted and native modes, the native mode is guaranteed to have exactly the same semantics as the interpreted mode.
4 thoughts on “Differences between Native and Interpreted Compilations in Oracle 11g? Why Performance Is Improved in the Native Compilation?”
thanks Ittichai, for the summary.
Here is the link to the metalink note :
How To Convert the Entire DB From INTERPRETED Mode to NATIVE or Vice Versa for PL/SQL [ID 1340441.1]
Victor, thanks for the link.
Hiya, I am really glad I have found this information. Nowadays bloggers publish only about gossips and internet and this is really annoying. A good website with interesting content, this is what I need. Thanks for keeping this website, I will be visiting it. Do you do newsletters? Can not find it.
Very good article.