分类: 数据库开发技术
2011-03-03 09:34:49
20,#檢查各個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
21,顯示各個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均衡
22,檢查哪個表具有最多的磁片I/0:
select dbsname, tabname, (isreads + pagreads)
diskreads,
(iswrites + pagwrites) diskwrites
from sysptprof
order by 3 desc,4 desc
#根據各個dbspaces的I/O來調整表的佈局,使整個系統I/O均衡
23,檢查表的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的數量
24,檢查表中索引的層數(越少越好):
select idxname, levels from sysindexes order by 2 desc
25,檢查命中率不高的索引(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
#當索引的效率不高的時候,需要根據實際情況修改
26,看資料庫裏面那些表的碎片比較多(碎片小比較好)
select dbsname , tabname ,count(*), sum(size)
from sysextents
group by 1,2
order by 3 desc;
27,表和索引的讀寫情況,(考查那個資料庫實體讀寫比較多)
select dbsname, tabname, (isreads + pagreads)
diskreads,
(iswrites + pagwrites)
diskwrites
from sysptprof
order by 3 desc, 4 desc
28,那些表的鎖競爭比較厲害(越小越好)
select a.tabname,nrows,lockwts,deadlks
from sysmaster:sysptprof a,systables b
where a.tabname=b.tabname and lockwts>0
and a.dbsname = name
and b.tabid >= 100
order by tabname;
29,表的順序掃描數(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;
30,查看informix資料庫表佔用空間大小情況:
#在sysmaster資料庫中查詢表systabnames,sysptnext。
#其中systabnames.partnum=sysptnext.pe_partnum.執行以下sql:
select tabname,sum(pe_size) from systabnames,sysptnext
where partnum=pe_partnum
and tabname='table_name'--(table_name?要查詢的表名)
group by tabname
#(注:查詢結果中pe_size的值,單位IBM是4k,HP-UX是2k)
#用onstat查是那個線程在幹的,然後再分析。
#我是用onstat -u查看到鎖數的。
#用onstat -g ses 找出session id
#再用onstat -g sql session
id查看它在做什?。
update statistics for table temp_user;