Performance Enhancement Guidelines for PL/SQL
Avoid usage of Union and select Distinct in your
queries .Replace them by Union All and OR.
Use the top operator to prevent excessive data return if
requirements allow
When you have choice use Where clause in the following
order of preference
. ! " !
#. !$%
&. !$"%
'. !("%
). !(%
*n a where clause search criteria at least
one highly selective column must be used
which is indexed. *f not available consider
using a covering index for the column.
Avoid +ql +tatements that are not
searchable by the query optimi,er .-he
following should be avoided *. A W/0R0
12AU+0 with innovative thin3ing.-his is
given in decreasing order of preference.
. *+ .ull
#. ($
&. .O-
'. .O- 04*+-+
). .O- *.
5. .O- 2*60
Example:
.O- *. can be replaced by proper use of exists
Don%t use functions on the right hand side of a query.
Avoid usage of +U7+-R*.8+
Use hints in your query if confident of overriding 9uery Optimi,er rules.
Don%t return redundant column data
/ere are the 3ey operands used in the W/0R0 clause: ordered by their
performance. -hose operands at the top will produce results faster than those
listed at the bottom.
. A single literal used by itself on one side of an operator
#. A single column name used by itself on one side of an operator: a
single parameter used by itself on one side of an operator
&. A multi;operand expression on one side of an operator
'. A single exact number on one side of an operator
). Other numeric number <other than exact=: date and time
5. 1haracter data: .U22s
When given a choice between *. And 0xists Use 0xists
*f the table is giving full scans then try to force index scan
if possible
Example
+0201- > ?RO@ tbl-as3Arocesses W/0R0 nextprocess "
A.D processid *. <B:&#:')=
ta3es about & seconds: whileC
+0201- > ?RO@ tbl-as3Arocesses <*.D04 " *4DArocess*D=
W/0R0 nextprocess " A.D processid *. <B:&#:')=
returns in under a second
When given a choice of usage of *. and 70-W00. use 70-W00.
Avoid using +tring concatenation in statements
And Operation usage
When using and try to use the condition that is
supposed to retrieve least noC of rows or which is least
li3ely to occur.
*f both the quries are equally li3ely then use the simpler
expression first
*f a column is supposed to be sorted often then use a clustered index on that
column.
@a3e use of rowid to update andEor select from a query as far as
situations allow.