一、登陸數據庫服務器,切換到informix用戶
infodb% su - informix
Password:
Sun Microsystems Inc. SunOS 5.8 Generic Patch February 2004
You have new mail.
二、查看一下onstat工具的用法
onstat 應用程序的功能是讀取共享內存的結構,提供執行該命令那一瞬間的統計數據。
在onstat 顯示輸出的過程中,共享內存的內容可能會發生變化。執行該操作不封鎖共享內存,因此不會影響操作運行。
它是informix提供的一種交互式的系統監控工具。
infodb% onstat --
usage: onstat [ -abcdfghklmpstuxzBCDFRX ] [ -i ] [ -r [<seconds>] ]
[ -o [<outfile>] ] [ <infile> ]
-a Print all info
-b Print buffers
-c Print configuration file
-d [update]
Print spaces and chunks
update - Ask server to update BLOB chunk statistics
-f Print dataskip status
-g MT subcommand (see subcommands below)
-i Interactive mode
-h Print buffer hash chain info
-j Print interactive status of the active onpload process
-k Print locks
-l Print logging
-m Print message log
-p Print profile
-s Print latches
-t Print TBLspaces
-u Print user threads
-x Print transactions
-z Zero profile counts
-B Print all buffers
-C Print btree cleaner requests
-D Print spaces and detailed chunk stats
-F Print page flushers
-G Print global transaction ids
-P Print partition buffer summary
-R Print LRU queues
-T Print tablespace information
-X Print entire list of sharers and waiters for buffers
-r Repeat options every <seconds> seconds (default: 5)
-o Put shared memory into specified file (default: onstat.out)
<infile>
Read shared memory information from specified dump file
MT COMMANDS:
all Print all MT information
ath Print all threads
wai Print waiting threads
act Print active threads
rea Print ready threads
sle Print all sleeping threads
spi Print spin locks with long spins
sch Print VP scheduler statistics
lmx Print all locked mutexes
lsc Print Light Scan information
wmx Print all mutexes with waiters
con Print conditions with waiters
stk <tid>
Dump the stack of a specified thread
glo Print MT global information
mem [<pool name>|<session id>]
Print pool statistics.
seg Print memory segment statistics
rbm Print block map for resident segment
nbm Print block map for non-resident segments
afr <pool name|session id>
Print allocated pool fragments
ffr <pool name|session id>
Print free pool fragments
ufr <pool name|session id>
Print pool usage breakdown
iov Print disk IO statistics by vp
iof Print disk IO statistics by chunk/file
iog Print AIO global information
iob Print big buffer usage by IO VP class
ppf [<partition number> | 0]
Print partition profiles
tpf [<tid> | 0]
Print thread profiles
ntu Print net user thread profile information
ntt Print net user thread access times
ntm Print net message information
ntd Print net dispatch information
nss [<session id>]
Print net shared memory status
nsc [<client id>]
Print net shared memory status
nsd Print net shared memory data
sts Print max and current stack sizes
dic Print dictionary cache information
opn [<tid>]
Print open tables
qst Print queue statistics
wst Print thread wait statistics
rwm print Read/Write Mutex lists
ses [<session id>]
Print session information
sql [<session id>]
Print SQL information
stq [<session id>]
Print stream queue information
smb Print smart-large-object usage
dri Print data replication information
pos Print /INFORMIXDIR/etc/.infos.DBSERVERNAME file
mgm Print Memory Grant Manager information
lap Print light append information
ddr Print DDR log post processing information
env [ all | [<session-id>] ] [<variable-name>[,<variable-name>...]]
Display environment variable settings.
dmp <address> <length>
Dump <length> bytes of shared memory starting at <address>
src <pattern> <mask>
Search memory for <pattern>, where <pattern>==(memory&<mask>)
dll Print dynamic library statistics
ssc [pool|all]
Prints ssc pool summary, or statement cache summary and
entries, including key only entries (all)
stm [<sesson id>]
Prints all prepared statements approximate memory usage in a session
主要選項說明如下:
-a 打印所有信息
-b 顯示正在使用的緩沖區
-B 顯示所有的緩沖區(不僅是正在使用的)
-c 顯示ONCONFIG 文件內容,數據庫首先檢測你是否定義了環境變量
ONCONFIG,若有則顯示 $INFORMIX/etc/$ONCONFIG 文件的內容,若未定義,則顯示$INFORMIX/etc/onconfig文件的內容,此文件包含了許多系統需要的定義和設置。
-C 顯示B+樹清除(B+ tree cleaner)情況
-d 顯示每個數據空間(dbspace)的塊(chunk)信息
-D 顯示每個數據空間頭50個塊的頁(page)讀寫的情況
-F 顯示每一種類型的寫回磁盤(flush pages to disk)的統計數
-h 顯示哈西鏈(hash chain)緩沖區信息
-i 進入onstat的交互方式,可直接敲入onstat命令,使用CTRL-d 退出交互方式
-k 顯示活動鎖(active lock)的信息
-l 顯示物理日志和邏輯日志的信息
-m 顯示20個系統最近用到的系統信息日志
-o file 將當前共享內存段內容寫入指定文件,缺省為 onstat.out
-p 顯示各項統計數
-r seconds 按指定秒數定期執行本次onstat命令,缺省為5秒,可用CTRL-c或DEL 鍵中止
-R 顯示 LRU隊列,FLRU隊列,MLRU隊列的詳細信息
-t 顯示活動(active)的表空間(tblspace)信息
-u 顯示用戶情況
-x 顯示事務(transaction)信息
-X 顯示正在共享(sharing)和等待(waiting)緩沖區的線索(thread)的精確信息
-z 將所有的統計計數置0
三、查看數據庫狀態
正常情況下是
infodb% onstat -
IBM Informix Dynamic Server Version 9.40.FC7 -- On-Line -- Up 35 days 16:51:16 -- 3920896 Kbytes
長事務情況下是
infodb% onstat -
IBM Informix Dynamic Server Version 9.40.FC7 -- On-Line (LONGTX) -- Up 35 days 16:41:40 -- 3920896 Kbytes
Blocked:LONGTX
四、顯示事務(transaction)信息
其中flag字段中第三個標志位為R說明事務在rollback,說明這個事務是長事務
infodb% onstat -x
IBM Informix Dynamic Server Version 9.40.FC7 -- On-Line (LONGTX) -- Up 35 days 16:41:56 -- 3920896 Kbytes
Blocked:LONGTX
Transactions
address flags userthread locks beginlg curlog logposit isol retrys coord
1cf0a6748 A-R-- 1cd55c618 642073 119403 119405 0x1aa91e4 DIRTY 0
1cf0a69b8 A---- 1d44f7ad0 1 0 0 0x0 COMMIT 0
278 active, 512 total, 447 maximum concurrent
五、通過長事務的userthread值找出session id
infodb% onstat -u |grep 1cd55c618
1cd55c618 --RPX-- 1880841 informix - 0 0 642073 256446 323049
六、顯示會話連接信息,找出造成長事務的SQL語句,並優化
infodb% onstat -g ses 1880841
IBM Informix Dynamic Server Version 9.40.FC7 -- On-Line (LONGTX) -- Up 35 days 16:42:40 -- 3920896 Kbytes
Blocked:LONGTX
session #RSAM total used dynamic
id user tty pid hostname threads memory memory explain
1880841 informix - 14283 infodb 1 417792 409528 off
tid name rstcb flags curstk status
1990929 sqlexec 1cd55c618 --RPX-- 14095 sleeping(Forever)
Memory pools count 1
name class addr totalsize freesize #allocfrag #freefrag
1880841 V 1cadeb040 417792 8264 592 14
name free used name free used
overhead 0 3248 mtmisc 0 80
scb 0 144 opentable 0 38792
filetable 0 5776 ru 0 600
log 0 2184 temprec 0 10104
keys 0 824 ralloc 0 278856
gentcb 0 1592 ostcb 0 2872
sort 0 136 sqscb 0 33384
sql 0 72 rdahead 0 608
hashfiletab 0 552 osenv 0 3240
buft_buffer 0 5312 sqtcb 0 6696
fragman 0 14144 shmblklist 0 152
udr 0 160
sqscb info
scb sqscb optofc pdqpriority sqlstats optcompind directives
1cdf2d028 1caf31028 0 0 0 0 1
Sess SQL Current Iso Lock SQL ISAM F.E.
Id Stmt type Database Lvl Mode ERR ERR Vers Explain
1880841 INSERT datadb DR Not Wait 0 0 9.03 Off
Stored procedure stack :
context proc-counter opcode name
------------------------------------------------------------------
0x00000001cbbfde60 0x1cacfcde8+0x0010 SQL datadb:datatodb
0x00000001cbbfde60 0x1cacfcde8+0x0010 SQL datadb:datatodb
Current SQL statement in procedure datadb:datatodb
proc-counter 0x1cacfcde8 opcode SQL
insert into userdb:alarm_tbl(column_1,column_2......column_n)
select column_1,column_2....column_n
from table_b as b, table_a as a, outer(table_c as c)
where a.column1=b.column and a.column_1=c.column_1......;
Last parsed SQL statement :
execute procedure datatodb()
User-created Temp tables :
partnum tabname rowsize
14000c5 c_list 38
14000c3 aa_list 34
infodb% su - informix
Password:
Sun Microsystems Inc. SunOS 5.8 Generic Patch February 2004
You have new mail.
二、查看一下onstat工具的用法
onstat 應用程序的功能是讀取共享內存的結構,提供執行該命令那一瞬間的統計數據。
在onstat 顯示輸出的過程中,共享內存的內容可能會發生變化。執行該操作不封鎖共享內存,因此不會影響操作運行。
它是informix提供的一種交互式的系統監控工具。
infodb% onstat --
usage: onstat [ -abcdfghklmpstuxzBCDFRX ] [ -i ] [ -r [<seconds>] ]
[ -o [<outfile>] ] [ <infile> ]
-a Print all info
-b Print buffers
-c Print configuration file
-d [update]
Print spaces and chunks
update - Ask server to update BLOB chunk statistics
-f Print dataskip status
-g MT subcommand (see subcommands below)
-i Interactive mode
-h Print buffer hash chain info
-j Print interactive status of the active onpload process
-k Print locks
-l Print logging
-m Print message log
-p Print profile
-s Print latches
-t Print TBLspaces
-u Print user threads
-x Print transactions
-z Zero profile counts
-B Print all buffers
-C Print btree cleaner requests
-D Print spaces and detailed chunk stats
-F Print page flushers
-G Print global transaction ids
-P Print partition buffer summary
-R Print LRU queues
-T Print tablespace information
-X Print entire list of sharers and waiters for buffers
-r Repeat options every <seconds> seconds (default: 5)
-o Put shared memory into specified file (default: onstat.out)
<infile>
Read shared memory information from specified dump file
MT COMMANDS:
all Print all MT information
ath Print all threads
wai Print waiting threads
act Print active threads
rea Print ready threads
sle Print all sleeping threads
spi Print spin locks with long spins
sch Print VP scheduler statistics
lmx Print all locked mutexes
lsc Print Light Scan information
wmx Print all mutexes with waiters
con Print conditions with waiters
stk <tid>
Dump the stack of a specified thread
glo Print MT global information
mem [<pool name>|<session id>]
Print pool statistics.
seg Print memory segment statistics
rbm Print block map for resident segment
nbm Print block map for non-resident segments
afr <pool name|session id>
Print allocated pool fragments
ffr <pool name|session id>
Print free pool fragments
ufr <pool name|session id>
Print pool usage breakdown
iov Print disk IO statistics by vp
iof Print disk IO statistics by chunk/file
iog Print AIO global information
iob Print big buffer usage by IO VP class
ppf [<partition number> | 0]
Print partition profiles
tpf [<tid> | 0]
Print thread profiles
ntu Print net user thread profile information
ntt Print net user thread access times
ntm Print net message information
ntd Print net dispatch information
nss [<session id>]
Print net shared memory status
nsc [<client id>]
Print net shared memory status
nsd Print net shared memory data
sts Print max and current stack sizes
dic Print dictionary cache information
opn [<tid>]
Print open tables
qst Print queue statistics
wst Print thread wait statistics
rwm print Read/Write Mutex lists
ses [<session id>]
Print session information
sql [<session id>]
Print SQL information
stq [<session id>]
Print stream queue information
smb Print smart-large-object usage
dri Print data replication information
pos Print /INFORMIXDIR/etc/.infos.DBSERVERNAME file
mgm Print Memory Grant Manager information
lap Print light append information
ddr Print DDR log post processing information
env [ all | [<session-id>] ] [<variable-name>[,<variable-name>...]]
Display environment variable settings.
dmp <address> <length>
Dump <length> bytes of shared memory starting at <address>
src <pattern> <mask>
Search memory for <pattern>, where <pattern>==(memory&<mask>)
dll Print dynamic library statistics
ssc [pool|all]
Prints ssc pool summary, or statement cache summary and
entries, including key only entries (all)
stm [<sesson id>]
Prints all prepared statements approximate memory usage in a session
主要選項說明如下:
-a 打印所有信息
-b 顯示正在使用的緩沖區
-B 顯示所有的緩沖區(不僅是正在使用的)
-c 顯示ONCONFIG 文件內容,數據庫首先檢測你是否定義了環境變量
ONCONFIG,若有則顯示 $INFORMIX/etc/$ONCONFIG 文件的內容,若未定義,則顯示$INFORMIX/etc/onconfig文件的內容,此文件包含了許多系統需要的定義和設置。
-C 顯示B+樹清除(B+ tree cleaner)情況
-d 顯示每個數據空間(dbspace)的塊(chunk)信息
-D 顯示每個數據空間頭50個塊的頁(page)讀寫的情況
-F 顯示每一種類型的寫回磁盤(flush pages to disk)的統計數
-h 顯示哈西鏈(hash chain)緩沖區信息
-i 進入onstat的交互方式,可直接敲入onstat命令,使用CTRL-d 退出交互方式
-k 顯示活動鎖(active lock)的信息
-l 顯示物理日志和邏輯日志的信息
-m 顯示20個系統最近用到的系統信息日志
-o file 將當前共享內存段內容寫入指定文件,缺省為 onstat.out
-p 顯示各項統計數
-r seconds 按指定秒數定期執行本次onstat命令,缺省為5秒,可用CTRL-c或DEL 鍵中止
-R 顯示 LRU隊列,FLRU隊列,MLRU隊列的詳細信息
-t 顯示活動(active)的表空間(tblspace)信息
-u 顯示用戶情況
-x 顯示事務(transaction)信息
-X 顯示正在共享(sharing)和等待(waiting)緩沖區的線索(thread)的精確信息
-z 將所有的統計計數置0
三、查看數據庫狀態
正常情況下是
infodb% onstat -
IBM Informix Dynamic Server Version 9.40.FC7 -- On-Line -- Up 35 days 16:51:16 -- 3920896 Kbytes
長事務情況下是
infodb% onstat -
IBM Informix Dynamic Server Version 9.40.FC7 -- On-Line (LONGTX) -- Up 35 days 16:41:40 -- 3920896 Kbytes
Blocked:LONGTX
四、顯示事務(transaction)信息
其中flag字段中第三個標志位為R說明事務在rollback,說明這個事務是長事務
infodb% onstat -x
IBM Informix Dynamic Server Version 9.40.FC7 -- On-Line (LONGTX) -- Up 35 days 16:41:56 -- 3920896 Kbytes
Blocked:LONGTX
Transactions
address flags userthread locks beginlg curlog logposit isol retrys coord
1cf0a6748 A-R-- 1cd55c618 642073 119403 119405 0x1aa91e4 DIRTY 0
1cf0a69b8 A---- 1d44f7ad0 1 0 0 0x0 COMMIT 0
278 active, 512 total, 447 maximum concurrent
五、通過長事務的userthread值找出session id
infodb% onstat -u |grep 1cd55c618
1cd55c618 --RPX-- 1880841 informix - 0 0 642073 256446 323049
六、顯示會話連接信息,找出造成長事務的SQL語句,並優化
infodb% onstat -g ses 1880841
IBM Informix Dynamic Server Version 9.40.FC7 -- On-Line (LONGTX) -- Up 35 days 16:42:40 -- 3920896 Kbytes
Blocked:LONGTX
session #RSAM total used dynamic
id user tty pid hostname threads memory memory explain
1880841 informix - 14283 infodb 1 417792 409528 off
tid name rstcb flags curstk status
1990929 sqlexec 1cd55c618 --RPX-- 14095 sleeping(Forever)
Memory pools count 1
name class addr totalsize freesize #allocfrag #freefrag
1880841 V 1cadeb040 417792 8264 592 14
name free used name free used
overhead 0 3248 mtmisc 0 80
scb 0 144 opentable 0 38792
filetable 0 5776 ru 0 600
log 0 2184 temprec 0 10104
keys 0 824 ralloc 0 278856
gentcb 0 1592 ostcb 0 2872
sort 0 136 sqscb 0 33384
sql 0 72 rdahead 0 608
hashfiletab 0 552 osenv 0 3240
buft_buffer 0 5312 sqtcb 0 6696
fragman 0 14144 shmblklist 0 152
udr 0 160
sqscb info
scb sqscb optofc pdqpriority sqlstats optcompind directives
1cdf2d028 1caf31028 0 0 0 0 1
Sess SQL Current Iso Lock SQL ISAM F.E.
Id Stmt type Database Lvl Mode ERR ERR Vers Explain
1880841 INSERT datadb DR Not Wait 0 0 9.03 Off
Stored procedure stack :
context proc-counter opcode name
------------------------------------------------------------------
0x00000001cbbfde60 0x1cacfcde8+0x0010 SQL datadb:datatodb
0x00000001cbbfde60 0x1cacfcde8+0x0010 SQL datadb:datatodb
Current SQL statement in procedure datadb:datatodb
proc-counter 0x1cacfcde8 opcode SQL
insert into userdb:alarm_tbl(column_1,column_2......column_n)
select column_1,column_2....column_n
from table_b as b, table_a as a, outer(table_c as c)
where a.column1=b.column and a.column_1=c.column_1......;
Last parsed SQL statement :
execute procedure datatodb()
User-created Temp tables :
partnum tabname rowsize
14000c5 c_list 38
14000c3 aa_list 34