ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 通过dba_hist_sqltext 等字典分析生产库某sql时快时慢

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

Linux操作系统 作者:evan_china 时间:2015-07-31 09:49:48 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/15108676/viewspace-1757385/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2011-06-04

  • 博文量
    6
  • 访问量
    15642