楼主: bosonmaster

日常维护的SQL(DOC版12月28日更新)

[复制链接]
论坛徽章:
10
每日论坛发贴之星
日期:2007-09-10 01:02:15金色在线徽章
日期:2007-10-03 04:03:16ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44数据库板块每日发贴之星
日期:2007-12-20 01:04:15生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53奥运会纪念徽章:摔跤
日期:2008-09-04 09:51:27生肖徽章2007版:狗
日期:2009-03-10 21:24:29ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42
11#
 楼主| 发表于 2007-12-19 12:15 | 只看该作者
Soft parse ratio:这项将显示系统是否有太多硬解析。该值将会与原始统计数据对比以确保精确。例如,软解析率仅为0.2则表示硬解析率太高。不过,如果总解析量(parse count total)偏低,这项值可以被忽略。

公式:1 - ( parse count (hard) / parse count (total) )

执行:

select 1-(a.value/b.value)

  from v$sysstat a,v$sysstat b

  Where a.name=’parse count (hard)’ and b.name=’parse count (total)’;

使用道具 举报

回复
论坛徽章:
10
每日论坛发贴之星
日期:2007-09-10 01:02:15金色在线徽章
日期:2007-10-03 04:03:16ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44数据库板块每日发贴之星
日期:2007-12-20 01:04:15生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53奥运会纪念徽章:摔跤
日期:2008-09-04 09:51:27生肖徽章2007版:狗
日期:2009-03-10 21:24:29ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42
12#
 楼主| 发表于 2007-12-19 12:15 | 只看该作者
In-memory sort ratio:该项显示内存中完成的排序所占比例。最理想状态下,在OLTP系统中,大部分排序不仅小并且能够完全在内存里完成排序。

公式:sorts (memory) / ( sorts (memory) + sorts (disk) )

执行:

select a.value/(b.value+c.value)

  from v$sysstat a,v$sysstat b,v$sysstat c

  where a.name=’sorts (memory)’ and

         b.name=’sorts (memory)’ and c.name=’sorts (disk)’;

使用道具 举报

回复
论坛徽章:
10
每日论坛发贴之星
日期:2007-09-10 01:02:15金色在线徽章
日期:2007-10-03 04:03:16ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44数据库板块每日发贴之星
日期:2007-12-20 01:04:15生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53奥运会纪念徽章:摔跤
日期:2008-09-04 09:51:27生肖徽章2007版:狗
日期:2009-03-10 21:24:29ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42
13#
 楼主| 发表于 2007-12-19 12:15 | 只看该作者
Parse to execute ratio:在生产环境,最理想状态是一条sql语句一次解析多数运行。

公式:1 - (parse count/execute count)

执行:

select 1-(a.value/b.value)

  from v$sysstat a,v$sysstat b

  where a.name=’parse count (total)’ and b.name=’execute count’;

使用道具 举报

回复
论坛徽章:
10
每日论坛发贴之星
日期:2007-09-10 01:02:15金色在线徽章
日期:2007-10-03 04:03:16ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44数据库板块每日发贴之星
日期:2007-12-20 01:04:15生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53奥运会纪念徽章:摔跤
日期:2008-09-04 09:51:27生肖徽章2007版:狗
日期:2009-03-10 21:24:29ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42
14#
 楼主| 发表于 2007-12-19 12:16 | 只看该作者
Parse CPU to total CPU ratio:该项显示总的CPU花费在执行及解析上的比率。如果这项比率较低,说明系统执行了太多的解析。

公式:1 - (parse time cpu / CPU used by this session)

执行:

select 1-(a.value/b.value)

  from v$sysstat a,v$sysstat b

  where a.name=’parse time cpu’ and

         b.name=’CPU used by this session’;

使用道具 举报

回复
论坛徽章:
10
每日论坛发贴之星
日期:2007-09-10 01:02:15金色在线徽章
日期:2007-10-03 04:03:16ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44数据库板块每日发贴之星
日期:2007-12-20 01:04:15生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53奥运会纪念徽章:摔跤
日期:2008-09-04 09:51:27生肖徽章2007版:狗
日期:2009-03-10 21:24:29ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42
15#
 楼主| 发表于 2007-12-19 12:16 | 只看该作者
Parse time CPU to parse time elapsed:通常,该项显示锁竞争比率。这项比率计算

是否时间花费在解析分配给CPU进行周期运算(即生产工作)。解析时间花费不在CPU周期运算通常表示由于锁竞争导致了时间花费

公式:parse time cpu / parse time elapsed

执行:

select a.value/b.value

  from v$sysstat a,v$sysstat b

  where a.name=’parse time cpu’ and b.name=’parse time elapsed’;

使用道具 举报

回复
论坛徽章:
10
每日论坛发贴之星
日期:2007-09-10 01:02:15金色在线徽章
日期:2007-10-03 04:03:16ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44数据库板块每日发贴之星
日期:2007-12-20 01:04:15生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53奥运会纪念徽章:摔跤
日期:2008-09-04 09:51:27生肖徽章2007版:狗
日期:2009-03-10 21:24:29ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42
16#
 楼主| 发表于 2007-12-19 12:16 | 只看该作者
从V$SYSSTAT获取负载间档(Load Profile)数据

  负载间档是监控系统吞吐量和负载变化的重要部分,该部分提供如下每秒和每个事务的统计信息:logons cumulative, parse count (total), parse count (hard), executes, physical reads, physical writes, block changes, and redo size.

  被格式化的数据可检查’rates’是否过高,或用于对比其它基线数据设置为识别system profile在期间如何变化。例如,计算每个事务中block changes可用如下公式:

db block changes / ( user commits + user rollbacks )

执行:

select a.value/(b.value+c.value)

  from v$sysstat a,v$sysstat b,v$sysstat c

  where a.name=’db block changes’ and

         b.name=’user commits’ and c.name=’user rollbacks’;

其它计算统计以衡量负载方式,如下:

l         Blocks changed for each read:这项显示出block changes在block reads中的比例。它将指出是否系统主要用于只读访问或是主要进行诸多数据操作(如:inserts/updates/deletes)

公式:db block changes / session logical reads

执行:

select a.value/b.value

  from v$sysstat a,v$sysstat b

  where a.name=’db block changes’ and

         b.name=’session logical reads’ ;

使用道具 举报

回复
论坛徽章:
10
每日论坛发贴之星
日期:2007-09-10 01:02:15金色在线徽章
日期:2007-10-03 04:03:16ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44数据库板块每日发贴之星
日期:2007-12-20 01:04:15生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53奥运会纪念徽章:摔跤
日期:2008-09-04 09:51:27生肖徽章2007版:狗
日期:2009-03-10 21:24:29ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42
17#
 楼主| 发表于 2007-12-19 12:16 | 只看该作者
Rows for each sort:

公式:sorts (rows) / ( sorts (memory) + sorts (disk) )

执行:

select a.value/(b.value+c.value)

  from v$sysstat a,v$sysstat b,v$sysstat c

  where a.name=’sorts (rows)’ and

         b.name=’sorts (memory)’ and c.name=’sorts (disk)’;

使用道具 举报

回复
论坛徽章:
10
每日论坛发贴之星
日期:2007-09-10 01:02:15金色在线徽章
日期:2007-10-03 04:03:16ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44数据库板块每日发贴之星
日期:2007-12-20 01:04:15生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53奥运会纪念徽章:摔跤
日期:2008-09-04 09:51:27生肖徽章2007版:狗
日期:2009-03-10 21:24:29ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42
18#
 楼主| 发表于 2007-12-19 12:20 | 只看该作者
查看某表的约束条件
            SQL>select constraint_name, constraint_type,search_condition, r_constraint_name
                from user_constraints where table_name = upper(’&table_name’);

        SQL>select c.constraint_name,c.constraint_type,cc.column_name
            from user_constraints c,user_cons_columns cc
            where c.owner = upper(’&table_owner’) and c.table_name = upper(’&table_name’)
            and c.owner = cc.owner and c.constraint_name = cc.constraint_name
            order by cc.position;

使用道具 举报

回复
论坛徽章:
10
每日论坛发贴之星
日期:2007-09-10 01:02:15金色在线徽章
日期:2007-10-03 04:03:16ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44数据库板块每日发贴之星
日期:2007-12-20 01:04:15生肖徽章2007版:猴
日期:2008-01-02 17:35:53生肖徽章2007版:鼠
日期:2008-01-02 17:35:53奥运会纪念徽章:摔跤
日期:2008-09-04 09:51:27生肖徽章2007版:狗
日期:2009-03-10 21:24:29ITPUB社区12周年站庆徽章
日期:2013-10-08 17:44:42
19#
 楼主| 发表于 2007-12-19 12:20 | 只看该作者
查看表空间的名称及大小

    select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
    from dba_tablespaces t, dba_data_files d
    where t.tablespace_name = d.tablespace_name
    group by t.tablespace_name;

使用道具 举报

回复
论坛徽章:
0
20#
发表于 2007-12-19 12:21 | 只看该作者
感谢楼主,这么辛苦当然得支持!!!

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表