2014年5月27日 星期二

informix table lock

select unique
 dbsname db,
 tabname ,
--zt02,
 case
 when type="S" then "shared lock"
 when type="IS" then "intent shared lock"
 when type="SIX" then "shared intent excl lock"
 when type="XS" then "shared key value by RR"
 when type="IX" then "intent excl lock"
 when type="X" then "exclusive lock"
 when type="XR" then "excl key value by RR"
 when type="U" then "update lock"
 when type="B" then "byte lock"
 else
 "unknown lock type"
 end lock_type,
 lpad(owner,5) ses_id,
 lpad(waiter,5) wait_id
 from sysmaster:syslocks
--  left outer join ds:zt_file on zt01=tabname
 where tabname != 'sysdatabases'

找出 wait_id 有值的.代表他在等某一個東西 release.

nstat -g ses | grep  88999  (note ses_id)
find session id to query processs id  再去KILL 他.




2014年5月6日 星期二

informix table extent 相關

Informix DB:
create table 時 informix 會先allocate 一個空間給這個TABLE 使用. 如果空間不夠時. informix 會再allocate 一個空間來使用.如果這二個空間剛好都是連在一起,在Informix 中我們叫他為一個 extent,資料庫長時間使用下有可能使得TABLE的EXTENT 值變大.大過一定值(200以上?) 會出現錯誤.這時我們就要重新規劃了.

先用以下命令去找.所有資料庫table extent與他的SIZE

select
     dbsname,
     tabname,partnum,
     count(*) num_of_extents,
     sum(pe_size) total_size
from
     systabnames, sysptnext
where
       partnum = pe_partnum
  and  partnum  > 99
  and  dbsname <> "sysmaster"
  and  dbsname <> "sysutils"
  and  tabname <> "TBLSpace"
group by 1,2,3
order by 1,5 desc ;

我查出我的MYTABLE001 他空用有201個EXTENT 共 771400 KB ,
這時我要先建一個TABLE 內容與原TABLE 名稱多加個_TEMP 並同時給他初始大小與增大大小(KB)

CREATE TABLE tiptop.mytable001_temp (
    imk01  CHAR(20),
    imk02  CHAR(10),
    imk03  CHAR(10),
    imk09  DECIMAL(15,3)
    )
EXTENT SIZE 921600 NEXT SIZE 61440
LOCK MODE PAGE

之後再把資料insert 到Temp table
insert into mytable001_temp select * from mytable001
再把原TABLE DROP, 再把temp table rename 到原table
drop table mytable001
RENAME TABLE mytable001_temp  TO mytable001
經過這次的轉換後.沒問題了.
注意.要先把原來的 trigger, index 相關語法備份下來喔