Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

PL/SQL Native Compilation in Oracle 11g

By Saurabh Gupta | on April 25, 2011 |
PL/SQL

During the introduction of Objects and Types in Oracle 8 release, PL/SQL was referred as procedural and object oriented language. While Oracle 9i and 10g were more concentrated on the sharpening of the object oriented model of Oracle, Oracle 11g aims at evolving PL/SQL from interpreted language to natively compiled language. In the tutorial, we shall see the changes made to achieve native compilation and its post application effects.

Interpreted to Native Compilation: A Tour

Native compilation of program units was first introduced in Oracle 9i release 1. Introduction of native compilation was taken as one of the revolutionary changes of 9i release. A PL/SQL source code could be natively compiled into machine code without seeking any efforts from an external Interpreter. With the help of C compiler, a C code source file was generated and linked to a shared library (DLL). During execution, Oracle executables made a call to the DLL whenever required.

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). Till 10g release, a third party compiler i.e. C compiler was used for the compilation of the source code and generating native DLLs.

Shared library management was identified as an overhead and an obvious performance bait at the server side. Database customers even raised issues on the Oracle credibility to rely on a third party compiler.

Native to Real Native Compilation

Oracle 11g renovated the native compilation by removing the third party compilation layer of program units and transforming the compilation process into a Real Native Compilation. Consequently, Oracle was able to win back its credibility among its customers and won the challenge by providing add-on benefits with the change, as listed below.

  • Reduces complication of setting bunch of parameters
  • No more dependency on C compiler. Saved licensing cost
  • No file system required for DLL storage
  • Compilation performance of program units enhanced by a decent fold of 2.5
  • Hybrid advantage of first two, code execution improved by ~40%
  • Improved scalability. It reduced contention within shared pool memory area by using PGA to create database catalog of shared code.
  • Faster arithmetic operations, branching operations and no action operations

Prior to Oracle 11g, bunch of initialization parameters have to be maintained to configure native Compilation.

  • plsql_native_make_utility to set the path of Make utility on db server
  • plsql_native_make_file_name to set the file name for the make utility
  • plsql_native_library_dir to set an existent path, where shared libraries would be stored
  • plsql_native_library_subdir_count to set maximum libraries that can reside in the plsql_native_library_dir
  • plsql_native_c_compiler and plsql_native_linker to specify full path of C compiler and linker on db server
  • plsql_compiler_flags to set the compilation mode as NATIVE or INTERPRETED

Oracle 11g deprecated the above parameters by inducting a single parameter which was efficient enough to set the compilation mode switching. This is because in Oracle 11g, natively compiled code is stored in database and not in any file system.

PLSQL_CODE_TYPE: New Initialization Parameter

PLSQL_CODE_TYPE is the new parameter included in the spfile.ora file, which accepts two values.

1. INTERPRETED – The conventional compilation technique which used to convert the code in byte code format, an intermediate format. It is stored in the database dictionary and would be loaded using an interpreter at run time. This is default value of the parameter.

2. NATIVE – Support real native compilation of program units.

The parameter can be set at the System or Session level using ALTER [SYSTEM | SESSION] command.

  1. ALTER SYSTEM SET PLSQL_CODE_TYPE = NATIVE
  2. ALTER SESSION SET PLSQL_CODE_TYPE = NATIVE

Once the PLSQL_CODE_TYPE parameter is set, all the objects would be natively compiler from there on.

Program units, which were created and compiled in earlier versions of Oracle, can be natively recompiled at the by setting PLSQL_CODE_TYPE at object level.

  1. ALTER [DATABASE Object] COMPILE PLSQL_CODE_TYPE = NATIVE

For example, a procedure P_INTERPRET was created in Oracle 9i and compiled in INTERPRETED mode. In Oracle 11g, it can be natively compiled as below.

  1. SQL>ALTER PROCEDURE P_INTERPRET COMPILE PLSQL_CODE_NATIVE
  2. PROCEDURE altered.

Object level compilation settings can be queried from [USER | DBA | ALL]_PLSQL_OBJECT_SETTINGS dictionary views.

  1. SQL>SELECT PLSQL_CODE_TYPE FROM ALL_PLSQL_OBJECT_SETTINGS WHERE NAME = ’P_INTERPRET’; 
  2.  
  3. PLSQL_CODE_TYPE
  4. ————————————————
  5. NATIVE

Another initialization parameter, which must be considered at low priority, is PLSQL_OPTIMIZE_LEVEL. It defines the scope of subprogram inlining for the optimizer. As per Oracle 11g enhancements, it can have 1, 2, and 3 as possible values. At the first optimization level (i.e. PLSQL_OPTIMIZE_LEVEL=1), Oracle server does not supports native compilation and this overrides the PLSQL_CODE_TYPE setting. For the optimal and commendable database performance, PLSQL_OPTIMIZE_LEVEL must hold the value 2.

Re-Compilation of Database Objects using Native Compilation in Oracle 11g

I will now describe the steps involved to upgrade the database to 11g, and re-compile the program units.

1. Set the PLSQL_CODE_TYPE

  1. SQL>ALTER SYSTEM SET PLSQL_CODE_TYPE=NATIVE SCOPE=SPFILE;
  2. System altered.

2. Set the PLSQL_OPTIMIZE_LEVEL to 2 i.e. logical inlining of subprograms

  1. SQL>ALTER SYSTEM SET PLSQL_OPTIMIZE_LEVEL=2 SCOPE=SPFILE;
  2. System altered.

3. Shutdown the Database
4. Startup the Database in UPGRADE mode
5. Execute the dbmsupgnv.sql script from the path @ORACLE_HOME/rdbms/admin/
6. Restart the Database

Vice-versa is also possible by setting the PLSQL_CODE_TYPE to INTERPRETED and executing dbmsupgin.sql from the same path.

Introduction of PL/SQL Data Type: SIMPLE_INTEGER

Oracle 11g introduces three new PL/SQL data type namely,
1. SIMPLE_INTEGER,
2. SIMPLE_FLOAT, and
3. SIMPLE_DOUBLE.

While the SIMPLE_INTEGER evolved from the primitive data type family, SIMPLE_FLOAT and SIMPLE_DOUBLE are its float value counterparts. Value precision of SIMPLE_INTEGER ranges between –2,147,483,648 to 2,147,483,647.

The newly introduced data types are efficient as compared to their earlier counterparts; reason being the missing of NULL checks and Value overflow checks. The semantics of these data types are in close sync with the native compilation feature of oracle 11g hardware operations. They are more suited, more compatible for applications built on 11g release and yield better performance than PLS_INTEGER.

Limitations of Native Compilation

• Cannot speed up SQL execution
• Native compilation could not upgrade complex mathematical operations

——————–

About the author

Saurbh Gupta is working as Oracle R&D Consultant and Oracle 11g Advanced PL/SQL Certified Professional.

« « Oracle 11g PL/SQL New Features
Oracle 11g Result Cache » »

Author Description

Avatar

Free Training

RSSSubscribe 0 Followers
  • Popular
  • Recent
  • Oracle PL/SQL Tutorial

    December 25, 2007 - 0 Comment
  • Download Free Oracle SQL Developer

    October 6, 2006 - 0 Comment
  • Oracle 11g PL/SQL New Features

    April 24, 2011 - 0 Comment
  • Oracle 11g SQL New Features

    May 15, 2011 - 0 Comment
  • Oracle 11g SQL New Features

    May 15, 2011 - 0 Comment
  • Oracle 11g PL/SQL New Features

    April 24, 2011 - 0 Comment
  • Oracle PL/SQL Tutorial

    December 25, 2007 - 0 Comment
  • Download Free Oracle SQL Developer

    October 6, 2006 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • Oracle 11g SQL New Features
  • Oracle 11g PL/SQL New Features
  • Oracle PL/SQL Tutorial
  • Download Free Oracle SQL Developer

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2023. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT