ITPub博客

首页 > 数据库 > Oracle > 【TUNE_ORACLE】检查统计信息是否过期SQL参考

【TUNE_ORACLE】检查统计信息是否过期SQL参考

原创 Oracle 作者:Attack_on_Jager 时间:2021-08-04 10:09:38 0 删除 编辑

实验环境

搭建平台:VMware Workstation

OS:RHEL 6.10

Grid&DB:Oracle 11.2.0.4


SQL参考

--1. 首先执行explain plan for,在plan_table中生成SQL的执行计划

explain plan for select ....


--2. 然后执行以下脚本检查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%'));


--3. 最后检查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%'));


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

请登录后发表评论 登录
全部评论
在某银行任职DBA,拥有多年数据库运维经验,擅长Oracle,MySQL。尤其擅长Oracle的SQL优化,数据库性能调优,数据库备份、恢复与迁移。拥有的认证:OCM 12c,OCM 11g,MySQL OCP,RHCE,阿里云ACP,巨杉SCDP,软考系统集成工程师认证,Oracle Iaas OCA,OBCA,TDSQL认证,TBase认证

注册时间:2021-01-11

  • 博文量
    142
  • 访问量
    483092