Query Pinning
Query Pinning
Database: PKEYSTAR
2.Generate AWRSQRPT report from last 7days time frame and find a
Good Execution Plan with less Elapsed Time from more Executions
and then get a confirmation from customer.
Eg:
Last Capture
# Plan Hash Value Total Elapsed Time(ms) Executions 1st Capture Snap ID
Snap ID
4 3693203796 21,159 136 22416 22426
Eg:
Eg:
BEGIN
DBMS_SQLTUNE.DROP_SQLSET(
END;
Eg:
[email protected]>BEGIN
DBMS_SQLTUNE.DROP_SQLSET(
END;
/ 2 3 4 5
BEGIN
ERROR at line 1:
ORA-13754: "SQL Tuning Set" "Load_19rmtp3m22xj2" does not exist for user
"SYS".
ORA-06512: at line 2
[email protected]>exec DBMS_SQLTUNE.CREATE_SQLSET('Load_19rmtp3m22xj2');
6.Capture good plan from AWR and load to SQL SET.(Replace with
AWR begin snap,end snap ,sql id,plan_hash_value)
declare
baseline_ref_cur DBMS_SQLTUNE.SQLSET_CURSOR;
begin
open baseline_ref_cur for
select VALUE(p) from table(
DBMS_SQLTUNE.SELECT_WORKLOAD_REPOSITORY(&begin_snap_id,
&end_snap_id,'sql_id='||CHR(39)||'&sql_id'||
CHR(39)||'',NULL,NULL,NULL,NULL,NULL,NULL,'ALL')) p;
DBMS_SQLTUNE.LOAD_SQLSET('Load_ 2hyfmnj7b068x',
baseline_ref_cur);
end;
/
Eg:
[email protected]>declare
2 baseline_ref_cursor DBMS_SQLTUNE.SQLSET_CURSOR;
3 begin
DBMS_SQLTUNE.LOAD_SQLSET('Load_19rmtp3m22xj2', baseline_ref_cursor);
6 7 end;
8 /
declare
my_integer pls_integer;
begin
DBMS_OUTPUT.PUT_line(my_integer);
end;
Eg:
[email protected]>set serveroutput on
declare
my_integer pls_integer;
begin
8 DBMS_OUTPUT.PUT_line(my_integer);
end;
9 10 /
Eg:
Eg:
Eg:
11. Verify whether SQL query running with Current Fixed Plan for
both node.
select ADDRESS, HASH_VALUE, OLD_HASH_VALUE, PLAN_HASH_VALUE from gV$SQLAREA where SQL_ID
like '19rmtp3m22xj2';
Eg:
[email protected]>select ADDRESS, HASH_VALUE, OLD_HASH_VALUE, PLAN_HASH_VALUE from GV$SQLAREA where SQL_ID like
'19rmtp3m22xj2';
ADDRESS HASH_VALUE OLD_HASH_VALUE PLAN_HASH_VALUE
12.To Double check ,Run AWRSQRPT report from next effected snap
interval for both node and make sure there is no multiple plan
running for single SQL ID.