Differences between Native and Interpreted Compilations in Oracle 11g? Why Performance Is Improved in the Native Compilation?

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 Responses to Differences between Native and Interpreted Compilations in Oracle 11g? Why Performance Is Improved in the Native Compilation?

  1. VJ November 14, 2011 at 11:19 am #

    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

    • ittichai November 14, 2011 at 11:24 am #

      Victor, thanks for the link.

  2. Margy Odette March 16, 2012 at 11:28 pm #

    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.

  3. Tarun November 12, 2012 at 3:48 am #

    Very good article.

Leave a Reply

Powered by WordPress. Designed by WooThemes