Professional Documents
Culture Documents
Oracle optimizer may not always choose the best execution plan
Using hints may improve the performance by changing the execution plan
oracle takes.
In each statement, the hint goes directly after the Select, Delete, or Update
keyword. A few hints use Insert.
Hints are placed in the /*+ */ tag, where the hint goes after the + sign
Approach hints
Access hints
Join hints
Misc. hints
1.Approach Hints:
FULL(table): Chooses a full table scan for the table, even if there is an index
available.
ORDERED: tables are joined in the order in which they appear in the FROM
clause.
LEADING(table): specified table is the first table used in the join order.
USE_HASH(table [table] ): Tables are joined using a hash join. Smaller table
is used to make a hash table on join key. The larger table is scanned using
hash table to find joined rows.
USE_NL(table [table]): Joins tables using nested loops join, using specified
table as inner join. For every row in outer table, oracle accesses every row in
inner table.
SESSION command. Once the trace file is generated you run the tkprof tool
against the trace file and then look at the output from the tkprof tool . This
can also be used to generate explain plan output.
57.What is explain plan and how is it used?
Ans: The EXPLAIN PLAN command is a tool to tune SQL statements. To use it
you must have an explain_table generated in the user you are running the
explain plan for. This is created using the utlxplan.sql script. Once the explain
plan table exists you run the explain plan command giving as its argument
the SQL statement to be explained. The explain_plan table is then queried to
see the execution plan of the statement. Explain plans can also be run using
tkprof.
EXPLAIN PLAN FOR
SELECT *
FROM emp e, dept d
WHERE e.deptno = d.deptno
AND
e.ename = 'SMITH';