Mallikarjun Ramadurg Mallik034: Follow Me by Search Mallik034 at Youtube / FB / Linkedin / Twitter / Blogspot / Instagram
Mallikarjun Ramadurg Mallik034: Follow Me by Search Mallik034 at Youtube / FB / Linkedin / Twitter / Blogspot / Instagram
Contents
What are the queries that are running?....................................................................................................................................................................................... 1
Get the rows fetched, if there is difference it means processing is happening...........................................................................................................................2
Get the sql_hash_value................................................................................................................................................................................................................. 3
Get the sql_Text............................................................................................................................................................................................................................ 4
Get the explain_plan..................................................................................................................................................................................................................... 4
Run AWR report and review......................................................................................................................................................................................................... 5
Solution......................................................................................................................................................................................................................................... 6
Profiling:........................................................................................................................................................................................................................................ 6
SQL> select sql_hash_value from v$session where sid='&sid'; Enter value for sid: 1075 old 1: select sql_hash_value
from v$session where sid='&sid' new 1: select sql_hash_value from v$session where sid='1075'
SQL_HASH_VALUE
--------------
928832585
select case when access_predicates is not null then 'A' else ' ' end || case when filter_predicates is not null then 'F' else
' ' end xms_pred, id xms_id,
lpad(' ',depth*1,' ')||operation || ' ' || options xms_plan_step, object_name xms_object_name,
cost xms_opt_cost, cardinality xms_opt_card, bytes
xms_opt_bytes,
optimizer xms_optimizer from
v$sql_plan where
hash_value in (&SQL_HASH_VALUE) and to_char(child_number) like '%';
Solution
Based the cost u can decide what to be done.
exec fnd_stats.gather_schema_statistics('ALL');
exec DBMS_STATS.GATHER_DICTIONARY_STATS;
exec DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;
execute dbms_stats.gather_schema_stats('SYS', method_opt=>'for all columns size 1', degree=>30,estimate_percent=>100,cascade=>true);
exec dbms_stats.gather_system_stats ('NOWORKLOAD');
4. Rebuild index.
Profiling:
Run awr_sql_history_orig.sql gives all plans for same query >>> Supply sql_id for this.
see if there is difference in the plans. Understand the plans. Eg : it may be picking different indexes. or it may be processing a different table first
(most indented operation).
Check with Application Team about when u find good plan, tag it and do sql profiling.
(use sql profiling only as a last option because oracle should have the liberty to pick better plan)
Note:
Also find why bad plan is getting picked.