通过dba_hist_sqltext 等字典分析生产库某sql时快时慢

1,查找历史sql
select * from dba_hist_sqltext where sql_text like '%PORTAL_ORDERBILL%' and sql_text like '%PORTAL_CONSIGNEE%';
2,查找历史sql的执行计划是否发生过变化,并在何时发生变化
select a.INSTANCE_NUMBER,                                                                                                              
       a.snap_id,                                                                                                                      
       a.sql_id,                                                                                                                       
       a.plan_hash_value,                                                                                                              
       to_char(b.begin_interval_time, 'yyyy-mm-dd hh24:mi:ss')                                                                         
  from dba_hist_sqlstat a, dba_hist_snapshot b                                                                                         
       WHERE                                                                                             
   a.snap_id = b.snap_id                                                                                                               
   and a.sql_id in(select sql_id from dba_hist_sqltext where sql_text like '%PORTAL_ORDERBILL%' and sql_text like '%PORTAL_CONSIGNEE%' )
   order by a.sql_id;
3,查找发生执行计划变化的两个差异
select plan_hash_value,                                                                                                                                                                                                                         
       id,                                                                                                               
       operation,                                                                                                        
       options,                                                                                                          
       object_name,                                                                                                      
       depth,                                                                                                            
       cost,                                                                                                             
       timestamp                                                                                                         
  from DBA_HIST_SQL_PLAN                                                                                                 
 where sql_id
 in(select sql_id from dba_hist_sqltext where sql_text like '%PORTAL_ORDERBILL%' and sql_text like '%PORTAL_CONSIGNEE%' )
                                                                                                                                                                       
   and plan_hash_value in (209417713, 2699309196)
   order by a.sql_id;
4,出现故障的执行计划对portal_orderbill的orderbill_date列进行了降序索引,

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-749629/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9240380/viewspace-749629/

你可能感兴趣的:(通过dba_hist_sqltext 等字典分析生产库某sql时快时慢)