ITPub博客

首页 > 数据库 > Oracle > 0227show all segment level statistics

0227show all segment level statistics

原创 Oracle 作者:lfree 时间:2018-02-27 16:56:36 0 删除 编辑

[20180227]show all segment level statistics.txt

https://orainternals.wordpress.com/2013/06/12/dude-where-is-my-redo/

REM Author : Riyaj Shamsudeen
prompt  To show all segment level statistics in one screen
prompt

set lines 140 pages 100
col owner format A12
col object_name format A30
col statistic_name format A30
col object_type format A10
col value format 99999999999
col perc format 99.99
undef statistic_name
break on statistic_name
with  segstats as (
       select * from (
         select inst_id, owner, object_name, object_type , value ,
        rank() over (partition by  inst_id, statistic_name order by value desc ) rnk , statistic_name
         from gv$segment_statistics
          where value >0  and statistic_name like '%'||'&&statistic_name' ||'%'
        ) where rnk <31
       )  ,
sumstats as ( select inst_id, statistic_name, sum(value) sum_value from gv$segment_statistics group by statistic_name, inst_id)
select a.inst_id, a.statistic_name, a.owner, a.object_name, a.object_type,a.value,(a.value/b.sum_value)*100 perc
    from segstats a ,   sumstats b
where a.statistic_name = b.statistic_name
and a.inst_id=b.inst_id
order by a.statistic_name, a.value desc

/
with  segstats as (
    select * from (
       select  inst_id, owner, object_name, object_type ,  statistic_name , value,
          rank ()  over (partition by  inst_id, statistic_name order by value desc )  rnk
       from (
         select inst_id, owner, object_name, object_type ,  statistic_name , sum(value) value
                 from gv$segment_statistics
          where value >0 and statistic_name like '%'||'&&statistic_name' ||'%'
         group by inst_id, owner, object_name, object_type, statistic_name
        )
     ) where rnk <31
    ),
sumstats as ( select inst_id, statistic_name, sum(value) sum_value from gv$segment_statistics group by statistic_name, inst_id)
select a.inst_id, a.statistic_name, a.owner, a.object_name, a.object_type,a.value,(a.value/b.sum_value)*100 perc
    from segstats a ,   sumstats b
where a.statistic_name = b.statistic_name
and a.inst_id=b.inst_id
order by a.statistic_name,  a.inst_id, a.value desc
/

--//做一个记录,也许以后工作有用.

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

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7970358