使用 onstat 观察会话、锁、I/O、检查点等;配合 top/vmstat/iostat 等 OS 工具定位瓶颈。
五 健康检查与日常巡检脚本
建议以 informix 用户建立每日/每周巡检任务(cron),汇总并告警。
示例 SQL(在 sysmaster 上执行)
各 dbspace 使用率
select name dbspace, sum(chksize) allocated, sum(nfree) free,
round(((sum(chksize)-sum(nfree))/sum(chksize))*100,2) “%used”
from sysdbspaces d, syschunks c where d.dbsnum=c.dbsnum
group by name order by 4 desc;
各 dbspace I/O
select d.name, f.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;
表级 I/O 排行
select dbsname, tabname, (isreads+pagreads) diskreads, (iswrites+pagwrites) diskwrites
from sysptprof order by 3 desc,4 desc limit 20;
表 extent 数量(>30 建议重建/调整 extent size)
select t.tabname, count() num_ext
from sysextents e, systables t where e.tabnum=t.tabnum and t.tabname not like ‘sys%’
group by 1 having count() > 30 order by 2 desc;
索引层数(levels 越少越好)
select idxname, levels from sysindexes order by 2 desc limit 20;