- 论坛徽章:
- 0
|
本帖最后由 hannibal 于 2011-08-03 21:09 编辑
6.显示使用最频繁的10个索引
select top 10 ObjectName, LogicalReads, PagesRead,UsedCount
from master..monOpenObjectActivity
where IndexID!=0
Order by LogicalReads desc, PagesRead desc
7.显示大表的索引数
select convert(varchar,object_name(A.id)) as tablename , count(1)-1 as index_cnt, row_count(db_id('db_name'),A.id) as row_cnt
from sysindexes A, sysobjects B
where A.indid != 255
and A.id = B.id and B.type = 'U'
group by A.id
having row_count(db_id('db_name'),A.id) > 10000
order by 2
列出表空间
select (d.name+"."+u.name+"."+o.name),((reserved_pgs(i.id,doampg) *
2048.0)/1048576),((data_pgs(i.id,doampg) * 2048.0)/1048576)
from sysobjects o, sysindexes i,
sysusers u, master..sysdatabases d
where d.dbid=db_id() and o.id=i.id and o.uid=u.uid
and reserved_pgs(i.id,doampg) > 0 and o.type='U'
order by data_pgs(i.id,doampg)/reserved_pgs(i.id,doampg)
To determine which currently executing queries are consuming the most CPU, and to list the text of those queries, enter:
select top 10 s.SPID, s.CpuTime, s.LogicalReads, t.SQLText
from master..monProcessStatement s, master..monProcessSQLText t
where s.SPID = t.SPID
and s.SPID != @@spid
order by s.CpuTime DESC, t.SPID,t.BatchID,t.LineNumber,t.SequenceInLine |
|