Sunteți pe pagina 1din 5

Futurematics.Pvt.

Ltd
Performans Tuning

EXPLAIN PLAN
Sql>explain plan set statement_id=’ID1’ for select * from u1.emp where
u1.emp.empno=66;
Sql>select operation,options,cost from plan_table where
statement_id=’ID1’;
----------------------------
-----------------------------------------------------------------------------------------

SQL Tracing : it gives information of multiple queries performed in


between when you activate set sql_trace=true until you make it false.

Create one table bolly with 10,000,00 rows without index by SYS user.
 Set the sql_trace parameter
 Trace the Query
 From tkprof utility convert trace file to readable output file.

SYS :
Sql>alter session set tracefile_identifier='outputfilename' ---- mbn
Sql>alter session set sql_trace=true;
Sql>select * from u1.emp where u1.emp.empno=1212;
Sql>alter session set sql_trace=false;
A trace file will be generated in user_dump_dest location .

cd /u01/app/oracle/diag/rdbms/prod/prod/trace/ prod_arcr_4715.trc

tkprof prod_arcr_4715.prf
outputfilename=mbn

Converting trace file into human readable format using tkprof utility
$tkprof u1.emp.trc

Tracing the query from user session through dbms_monitor Pl/sql


package

FUTUREMATIC PVT LTD


Futurematics.Pvt.Ltd
Performans Tuning
Sql>exec
dbms_monitor.session_trace_enable(SESSION_ID=>34,SERIAL_NUM=>2
3);
 Ask the user to run the query from his own session
 Once the query is processed then disable the trace session.
Sql>exec
dbms_monitor.session_trace_disable(SESSION_ID=>34,SERIAL_NUM=
>23);

* From tkprof utility convert trace file to readable output file

--------------------------------------------------------------------------------------------
-------------------------------------

AWR REPORT (Automatic Workload Repository)

Taking snapshot
Sql>exec dbms_workload_repository.create_snapshot;

Generating AWR report


Sql>@$ORACLE_HOME/rdbms/admin/awrrpt.sql; ----- awr file location.
Need to run this file at sql ….n u can generate this file newhere at O.S lvl. If
u wan to generate at /u01…..in background u need to b there at /u01

Modifying the default setting of snapshots


Sql> exec
dbms_workload_repository.modify_snapshot_setting(retention=>43200
,interval=>30);

Dropping the snapshots


Sql>exec
dbms_workload_repository.drop_snapshot_range(low_snap_id=>22,
high_snap_id=>32);

Wait event in awr report

FUTUREMATIC PVT LTD


Futurematics.Pvt.Ltd
Performans Tuning
a)db_file scattered read :=>this wait event usually cause by large full table
scan
b)db_file sequential read:=>this wait event usually cause when problem
with join
operation.and wait on range or index scan.
c)buffer busy:=>this event is caused by concurrent acces to buffer in buffer
cache.
d)free buffer:=>this event indicate that oracle waited many times for free
buffer in buffer
cache
f)latch free:=>this event is often caused by not using bind variable in sql
statement;

ADDM(Automatic Database Diagnostic Monitor)


=======================================
Generating addm report
Sql>@$ORACLE_HOME/rdbms/admin/addmrpt.sql;

Generating Ash report


Sql>$ORACLE_HOME/rdbms/admin/ashrpt.sql;

SQL AUTO -TUNNING


Pkg => dbms_sqltune

Major Steps :
 Create Tuning tasks.
 Execute Tuning tasks.
 Report Tuning Task.

Sql>set serveroutput on

1) Create Tuning Task :

Sql>declare
v_ec varchar2(2500);
begin
v_ec := dbms_sqltune.create_tuning_task(sql_text=>’select * from
u1.emp
FUTUREMATIC PVT LTD
Futurematics.Pvt.Ltd
Performans Tuning
where u1.emp.empno=1232’);
dbms_output.put_line(v_ec);
end;
/

2) Execute Tuning Task :

Sql>exec dbms_sqltune.execute_tuning_task(TASK_NAME=>’TASK_12’);

3) Report Tuning Task :

Sql>declare
v_ec varchar2(2500);
begin
v_ec := dbms_sqltune.report_tuning_task(TASK_NAME=’TASK_12’);
dbms_output.put_line(v_ec);
end ;
/

Now it will give some recommendations to improve the performance of sql


query .

Segment advisory:

BEGIN
for i in 1..100000 LOOP
if mod(i,2)=0 then
INSERT INTO bolly(id,name,gender,salary,pan,address)
VALUES
(i,concat('SALLU',i),'male',i*10,concat('pan',i),concat('ind
ia',i));
else
INSERT INTO bolly(id,name,gender,salary,pan,address)

FUTUREMATIC PVT LTD


Futurematics.Pvt.Ltd
Performans Tuning
VALUES
(i,concat('KAT',i),'female',i*100,concat('pan',i),concat('in
dia',i));
end if;
END LOOP;
END;
/

FUTUREMATIC PVT LTD

S-ar putea să vă placă și