当前位置: 首页 > 图文教程 > 数据库 > MSSQL > 推荐:监控数据库性能的SQL语句汇总

MSSQL
巧用SQL链接服务器访问远程Access数据库
SQL Server如何删除群集实例
安装SQL 2005中的AdventureWorks数据库
SQL Server 2008中有关XML的新功能
SQL Server注入大全及防御
Sql Server 2000视图中小心使用*符号
Sql Server导出指定条件的数据
SQL Server 2008的在线事务处理
介绍SQL Server 2008的四项新特性
SQL Server 2008在数据仓库方面的一些优点
触发器对SQL Server数据库进行备份
设置在Access项目中检索的记录数
SQL Server关于SQL Agent使用技巧
把sql server所有表的所有者改为dbo
IIS、SQL Server和ASP.NET安全设置解决方案
SQL Server 2005日志文件损坏怎么办?
SQL Server数据库字典SQL语句
临时表在SQL Server和MySql中创建的方法
SQL Server数据库查询优化3种技巧
SQL Server数据库开发10个问题

MSSQL 中的 推荐:监控数据库性能的SQL语句汇总


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 121 ::
收藏到网摘: n/a

下面是一些监控数据库性能的SQL语句,希望对大家有帮助:

1. 监控事例的等待

  select  event,  sum(decode(wait_Time,0,0,1)) "Prev",  sum(decode(wait_Time,0,1,0)) "Curr",  count(*) "Tot"  from v$session_Wait  group by event  order by 4; 
 

2. 回滚段的争用情况

  select  name, waits, gets, waits/gets "Ratio"  from v$rollstat a, v$rollname b  where a.usn = b.usn; 
 

3. 监控表空间的 I/O 比例

  select  df.tablespace_name name,df.file_name "file",f.phyrds pyr,  f.phyblkrd pbr,f.phywrts pyw, f.phyblkwrt pbw  from v$filestat f, dba_data_files df  where f.file# = df.file_id  order by df.tablespace_name; 
 

4. 监控文件系统的 I/O 比例

  select  substr(a.file#,1,2) "#", substr(a.name,1,30) "Name",  a.status, a.bytes, b.phyrds, b.phywrts  from v$datafile a, v$filestat b  where a.file# = b.file#; 
 

5.在某个用户下找所有的索引

  select  user_indexes.table_name,  user_indexes.index_name,  uniqueness,  column_name  from user_ind_columns, user_indexes  where user_ind_columns.index_name = user_indexes.index_name and  user_ind_columns.table_name = user_indexes.table_name  order by user_indexes.table_type, user_indexes.table_name,  user_indexes.index_name, column_position; 
 

6. 监控 SGA 的命中率

  select  a.value + b.value "logical_reads",  c.value "phys_reads",  round(100 * ((a.value+b.value)-c.value) / (a.value+b.value)) "BUFFER HIT RATIO"  from v$sysstat a, v$sysstat b, v$sysstat c  where a.statistic# = 38 and b.statistic# = 39 and  c.statistic# = 40; 
 

7. 监控 SGA 中字典缓冲区的命中率