zoukankan      html  css  js  c++  java
  • 多个表关联或者有视图套视图,快速检查SQL语句中所有的表统计信息是否过期

    多个表关联或者有视图套视图,快速检查SQL语句中所有的表统计信息是否过期
    现有如下SQL:
    select * from emp e,dept d where e.deptno=d.deptno;
     
    先用explain plan for命令,在plan_table中生成SQL的执行计划:
     
    SQL> explain plan for select * from emp e,dept d where e.deptno=d.deptno;
     
    Explained.
     
    然后使用下面脚本检查SQL语句中所有的表的统计信息是否过期:
     
    SQL> select owner, table_name, object_type, stale_stats, last_analyzed
    from dba_tab_statistics
    where (owner, table_name) in
    (select object_owner, object_name
    from plan_table
    where object_type like '%TABLE%'
    union
    select table_owner, table_name
    from dba_indexes
    where (owner, index_name) in
    (select object_owner, object_name
    from plan_table
    where object_type like '%INDEX%'));
     
    OWNER TABLE_NAME OBJECT_TYP STALE_STATS LAST_ANALYZED
    ---------- ---------- ---------- --------------- ------------------
    SCOTT DEPT TABLE NO 05-DEC-16
    SCOTT EMP TABLE YES 22-OCT-16
     
     
    最后可以使用下面脚本检查SQL语句中表统计信息的过期原因:
     
    select *
      from all_tab_modifications
     where (table_owner, table_name) in
           (select object_owner, object_name
              from plan_table
             where object_type like '%TABLE%'
            union
            select table_owner, table_name
              from dba_indexes
             where (owner, index_name) in
                   (select object_owner, object_name
                      from plan_table
                     where object_type like '%INDEX%'));
     
     
     
  • 相关阅读:
    python3.5: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
    php回溯
    PHPredis长连接pconnect
    php操作redis出现不报错就退出
    MSMQ消息队列
    消息队列使用的四种场景介绍(准载)
    Spring MVC参数封装传递
    Spring MVC配置实例
    .NET项目中使用PostSharp
    C#进阶系列——AOP
  • 原文地址:https://www.cnblogs.com/liang545621/p/12611893.html
Copyright © 2011-2022 走看看