- 论坛徽章:
- 0
|
我也贴两个我常用的脚本
看数据库里面那些表的碎片比较多(碎片小比较好)
select dbsname , tabname ,count(*), sum(size)
from sysextents
group by 1,2
order by 3 desc;
表和索引的读写情况,(考查那个数据库实体读写比较多)
select dbsname, tabname, (isreads + pagreads) diskreads, (iswrites + pagwrites)
diskwrites
from sysptprof
order by 3 desc, 4 desc
那些表的锁竞争比较厉害(越小越好)
select a.tabname,nrows,lockwts,deadlks
from sysmaster:sysptprof a,systables b
where a.tabname=b.tabname and lockwts>0
and a.dbsname = 库名
and b.tabid >= 100
order by tabname;
表的顺序扫描数(OLTP系统的话,大表的顺序扫描数越小越好)
select a.tabname,nrows,seqscans
from sysmaster:sysptprof a,systables b
where a.tabname=b.tabname and seqscans>0
and a.dbsname = '库名'
and b.tabid>=100
order by tabname; |
|