Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
5.97 Mб


Tuning PL/SQL Applications for Performance

Every day, in every way, I am getting better and better. —Émile Coué

This chapter shows you how to write efficient PL/SQL code, and speed up existing code.

This chapter contains these topics:

How PL/SQL Optimizes Your Programs on page 11-1

Guidelines for Avoiding PL/SQL Performance Problems on page 11-2

Profiling and Tracing PL/SQL Programs on page 11-6

Reducing Loop Overhead for DML Statements and Queries (FORALL, BULK COLLECT) on page 11-7

Writing Computation-Intensive Programs in PL/SQL on page 11-19

Tuning Dynamic SQL with EXECUTE IMMEDIATE and Cursor Variables on page 11-19

Tuning PL/SQL Procedure Calls with the NOCOPY Compiler Hint on page 11-20

Compiling PL/SQL Code for Native Execution on page 11-22

Overview of Table Functions on page 11-28

How PL/SQL Optimizes Your Programs

In releases prior to 10g, the PL/SQL compiler translated your code to machine code without applying many changes for performance. Now, PL/SQL uses an optimizing compiler that can rearrange code for better performance.

You do not need to do anything to get the benefits of this new optimizer. It is enabled by default. In rare cases, if the overhead of the optimizer makes compilation of very large applications take too long, you might lower the optimization by setting the initialization parameter PLSQL_OPTIMIZE_LEVEL=1 instead of its default value 2. In even rarer cases, you might see a change in exception behavior, either an exception that is not raised at all, or one that is raised earlier than expected. Setting PL_SQL_OPTIMIZE_LEVEL=0 prevents the code from being rearranged at all.

When to Tune PL/SQL Code

The information in this chapter is especially valuable if you are responsible for:

Tuning PL/SQL Applications for Performance 11-1

Соседние файлы в папке Oracle 10g