打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Informix 数据库日常维护脚本
Informix 数据库日常维护脚本
 
作者:czw1413_cn  出处:Unix爱好者家园unix-cd.com  更新时间: 2005年12月16日 
为了提高日常维护IDS的效率,特提供以下脚本供大家参考。


检查各个dbspaces的空间使用状况:
select name dbspace,sum(chksize) allocated,sum(nfree) free,round(((sum(chksize)-sum(nfree))/sum(chksize))*100)||"%" pcused
form sysdbspaces d,syschunks c
where d.dbsnum=c.dbsnum group by name order by 4 desc
剩余空间肯定是越大越好了

显示各个dbspaces的I/O状况:
select d.name,fname path_name,sum(pagesread) diskreads,sum(pageswritten) diskwrites
from syschkio c,syschunks k,sysdbspaces d
where d.dbsnum=k.dbsnum and k.chknum=c.chunknum
group by 1,2 order by 3 desc
根据各个dbspaces的I/O来调整表的布局,使整个系统I/O均衡

检查哪个表具有最多的磁盘I/0:
select dbsname, tabname, (isreads + pagreads) diskreads, (iswrites + pagwrites) diskwrites
from sysptprof
order by 3 desc,4 desc
同上。


检查表的extent的分布状况:
select t.tabname, count(*) num_ext
from sysextents e, npmdb:systables t
where e.tabname=t.tabname
and dbsname = "npmdb"
and t.tabname not like "sys%"
group by 1
having count(*) > 1
order by 2 desc
表的extent建议最大不超过30个,如果太大,就需要重建表修改extent size的大小从而修改extent的数量

检查表中索引的层数(越少越好):
select idxname, levels from sysindexes order by 2 desc

检查命中率不高的索引(nrows和unique越接近越好):
select tabname, idxname, nrows, nunique
from systables t, sysindexes I
where t.tabid =i.tabid and t.tabid > 99
and nrows > 0 and nunique > 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; 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Oracle数据库SQL速查
数据库基本sql语句 - 自强不息 厚德载物 - ITeye技术网站
常用的sql语句
深入浅出Oracle学习笔记(9)
常用SQL语句书写技巧 - SQL Server - 数据库 - 程序员之家
写信念
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服