Professional Documents
Culture Documents
Choose
First_row
Rule
Description
Used the cost based
approach for best
throughput. Its a default
in oracle 11g.
If statistics are available
will use cost else rule.
Use cost based approach
for best response time.
Use rules based
approach. This cancels
only if other hints
specified for the
statement. This hint is an
out dated hint.
If statistics are not gathered from a long time for emp table
in choose hints display rule based otherwise it will display
cost based result.
How to gather table statistics:
Old method:
Sql> analyze table emp compute statistics;
New method:
Sql> exec DBMS_STATS.gather_table_stats(ownname => 'scott',tabname =>
'EMP');
Hints Name
Cluster(table)
Full(table)
Hash(table)
Rowid(table)
Index
Description
Its tell to the optimizer to
do cluster scan to access
the table.
This tells to the optimizer
to do a full scan of the
specified table
Tells to oracle to explicitly
chose the hash access
method for the table.
Forces rowid scan of the
specified table
Forces a index scan of
the specified table using
the specified index(s). if
list of indexes are
specified , the optimizer
choose the one with the
lowest cost. If no index
specified then optimizer
Index_Asc
Index_Desc
Index_combine
Index_join
Index_ss
Index_ffs
No_index
e.g:
Sql> select /*+ index(e emp_department_ix)
*/empid,ename,deptid from emp e where
deptno<=40;
In this above example emp_department_ix is a index
in deptno column of emp table and e is a table alias
of emp table.
Sql> select /*+ index_combine(e
emp_stats_btm_flag_ix job_id_bmp_index) */* from
emp e where emp_status=Training or job_id=Irprogramer;
In the above example emp_stats_btm_flag_ix and
job_id_bmp_index are both bitmap index for the
columns emp_status and job_id respectively.
Sql> select /*+ index_join(e emp_manager_indx
emp_dept_indx) */empid,ename from emp e where
empid<145 and deptno<60;
Sql> select /*+ index_ss(e emp_name_indx)
*/empno,ename from emp e where ename=King;
Sql> select /*+ index_ffs(e emp_name_indx)
*/ename from emp;
3. Hints for join operation:
Hints Name
Use_hash
Description
Forces the optimizer to join
each specified table with
another row source using a
hash join.
Use_merge
Use_nl
Use_nl_with_index
No_use_nl
No_use_hash
No_use_merge
Examples:
Sql> select /*+ use_nl_with_index(e empl_dept_index) */*
from empl e,dept d where e.deptno=d.deptno and
e.deptno<=40;
Sql> select /*+ no_use_hash(e d) */empid,ename from emp
e,dept d where e.deptno=d.deptno;
Description
This hints causes oracle to use
Ordered
Examples:
Sql> select /*+ leading(e s) */ * from emp e,dept
d ,sal_grade s
Where e.deptno=d.deptno and e.sal=j.hsal;
5. Hints for parallel execution:
Hints Name
Parallel
Parallel(Auto)
Parallel(Manual)
Parallel(Integer)
Description
This statement always
will run parallel and the
database computes the
degree or parallelism
which can be 2 or more.
The DB computes the
degree of parallelism,
which can be 1 or more.
If the computed
parallelism is 1, then the
statement runs serially.
The optimizer is forced
to use the parallel
setting of the objects in
the statement.
The optimizer uses the
degree of parallelism
Paralle_index
PQ_distribute
No_parallel
No_parallel_index
specified by integer.
Its instruct to the
optimizer to use
specified no of
concurrent server to
parallelize index range
scan, full scan and fast
full scans for patronized
indexes.
This can control the
distribution of rows for
parallel sql statement to
direct how rows should
be distributed between
the producer (Query)
and the consumer (Load)
server. It can improve
the parallel join
operation performance
when using partition
tables.
It overrides parallel
parameter in DDL thats
create or alter the table.
Overrides a parallel
parameter in DDL that
created or altered the
index thus avoiding the
parallel index scan
operation.
Examples:
Sql> select /*+ parallel */ empid,ename from emp;
Append_values
Noappend
Cache
Description
Its instruct the optimizer to us
direct pth insert.(table must b
alter with nologin mode)
It instruct the optimizer to use
direct path insert with the
values clause. If you do not
specify this hints then
conventional insert can used.
Its a new hints in oracle 11g R
and its very useful in forall
insert in pl sql block.
It use conventional insert by
disable parallel mode for the
duration of the insert
statement.
Conventional insert is default
serial mode. The direct path
insert is default in parallel
mode.
This hint instructs the optimize
to place the blocks received fo
the table at the most recently
Nocache
Result_cache
Examples:
Sql> set autotrace off;
Sql> sho parameter result_cache;