0% found this document useful (0 votes)
59 views

Tuning Oracle PL/SQL: Code Optimization

PL/SQL is Oracle's procedural language extension of SQL that allows developers to write complex application logic within the database. Some advantages of PL/SQL over SQL are that it can be stored and compiled within the database reducing overhead, it operates entirely on the database server reducing network traffic, and it enables writing triggers and functions. When implementing PL/SQL, its performance can be improved by storing routines as stored programs, optimizing procedural constructs like loops and branches, and using PL/SQL-specific features to optimize database access. Code optimization techniques include minimizing loop processing, optimizing conditional statements, and avoiding recursion to reduce unnecessary CPU usage from PL/SQL alone.

Uploaded by

SunyOra
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Tuning Oracle PL/SQL: Code Optimization

PL/SQL is Oracle's procedural language extension of SQL that allows developers to write complex application logic within the database. Some advantages of PL/SQL over SQL are that it can be stored and compiled within the database reducing overhead, it operates entirely on the database server reducing network traffic, and it enables writing triggers and functions. When implementing PL/SQL, its performance can be improved by storing routines as stored programs, optimizing procedural constructs like loops and branches, and using PL/SQL-specific features to optimize database access. Code optimization techniques include minimizing loop processing, optimizing conditional statements, and avoiding recursion to reduce unnecessary CPU usage from PL/SQL alone.

Uploaded by

SunyOra
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Tuning Oracle PL/SQL

PL/SQL - Oracle's procedural extensions to the SQL language - can be used to implement
complex application or data retrieval logic which cannot easily be expressed in single
SQL statements. PL/SQL plays a big part in many applications - particularly client-server
applications where PL/SQL can be used to implement application logic within the
database server itself.
PL/SQL has some advantages over standard SQL:

It can be stored in compiled form within the database. This reduces the overhead
of preparing an SQL statement for execution (parsing).
It operates completely within the server environment, eliminating or reducing
client-server and network traffic.
It allows the programmer to fully specify the processing logic and to implement
data access paths which might not be possible using standard SQL.
Using PL/SQL you can write triggers, which fire automatically when database
changes are made, and user-defined functions which can be embedded in your
SQL code.

Having decided to implement some processing in PL/SQL, whether as a replacement for


standard SQL or to implement some complex application logic, we have some
opportunities for improving the performance of that PL/SQL:

The procedural constructs in PL/SQL (loops, branches, etc.) are subject to many
of the same optimization techniques appropriate for other procedural languages
Storing PL/SQL routines in the database as a stored program reduces the overhead
of parsing PL/SQL.
There are some PL/SQL specific techniques which can be used to improve
database access (for instance, explicit cursors, CURRENT OF CURSOR, PL/SQL
tables).

Code Optimization
Usually, we think of PL/SQL as a database access language and concentrate on
optimizing the SQL within the PL/SQL program. But as a procedural language, PL/SQL
is subject to many of the same principles of optimization as other languages. There are
circumstances in which PL/SQL itself - without any database accesses - can consume
CPU resources at an excessive rate. Some of the basic principles for optimizing PL/SQL
code (and indeed other languages) are:

Optimize or minimize loop processing.


Optimize conditional statements (such as IF).
Avoid recursion.

You might also like