DB2快照監視器
--快照監視器開關
快照開關 DBM引數 快照資訊BUFFERPOOL DFT_MON_BUFPOOL 緩衝池讀寫資訊
LOCK DFT_MON_LOCK 鎖資訊
SORT DFT_MON_SORT 排序堆大小
STATEMENT DFT_MON_STMT 語句
TABLE DFT_MON_TABLE 表讀寫資訊
TIMESTAMP DFT_MON_TIMESTAMP 各種時間資訊
UOW DFT_MON_UOW 事務相關資訊
--例項級開啟
db2 update dbm cfg using DFT_MON_BUFPOOL on DFT_MON_LOCK on DFT_MON_STMT on DFT_MON_UOW on
db2 update dbm cfg using DFT_MON_TIMESTAMP on DFT_MON_SORT on DFT_MON_TABLE on
--資料庫session級開啟 (db2 terminate 後關閉)
db2 update monitor switches using BUFFERPOOL on
--重置快照開關
db2 reset monitor for db testdb all
--快照開關
db2 get monitor switches
--找到執行時間最長的20條語句
db2 "select rows_read/(num_executions+1) as avg_rows_read,
rows_written/(num_executions+1) as avg_rows_write,
stmt_sorts/(num_executions+1) as avg_sorts,
total_exec_time/(num_executions+1) as avg_exec_time,
substr(stmt_text,1,100) as sql_stmt
from sysibmadm.snapdyn_sql
order by avg_exec_time desc
fetch first 20 rows only
"
取出前10 大最耗資源的SQL語句:
select (TOTAL_USR_CPU_TIME + TOTAL_SYS_CPU_TIME) as totaltime, NUM_EXECUTIONS,
SORT_OVERFLOWS, TOTAL_SORT_TIME, STMT_TEXT
from sysibmadm.snapdyn_sql
order by totaltime desc fetch first 10 rows only
-------------------------------------------------------------
--snapshot 命令列
db2 get snapshot for all on $DB
db2 get snapshot for database manager
db2 get snapshot for database on $DB
db2 get snapshot for applications on $DB
db2 get snapshot for tables on $DB
db2 get snapshot for tablespaces on $DB
db2 get snapshot for locks on $DB
db2 get snapshot for bufferpools on $DB
db2 get snapshot for dynamic sql on $DB
db2 get snapshot for application agentid id_num 某一應用的快照
If you notice that there is one particular statement in the output of this SQL that has a long
average execution time and performs three sorts per execution, you can use the Design Advisor
to help tune this statement. If you extract the statement text from the output above, and put it into
the file bad.sql, you can run the Design Advisor from the command line using:
db2advis –d posdb –i bad.sql
If an index will help the performance of the query, the Index Advisor will tell you the definition
of the index or indexes it recommends, as well as the new cost of the query and the percent
improvement in the cost.
C:\temp>db2advis -d posdb -i bad.sql
Using user id as default schema name. Use -n option to specify schema
execution started at timestamp 2006-03-28-12.51.39.570001
found [1] SQL statements from the input file
Recommending indexes...
total disk space needed for initial set [ 0.009] MB
total disk space constrained to [ 33.322] MB
Trying variations of the solution set.
Optimization finished.
2 indexes in current solution
[ 13.0000] timerons (without recommendations)
[ 0.1983] timerons (with current solution)
[98.47%] improvement
--
--
-- LIST OF RECOMMENDED INDEXES
-- ===========================
-- index[1], 0.009MB
CREATE INDEX "DSNOW "."IDX403281751440000" ON "DSNOW "."ORGX" ("C1" ASC) ALLOW
REVERSE SCANS ;
COMMIT WORK ;
RUNSTATS ON TABLE "DSNOW "."ORGX" FOR INDEX "DSNOW "."IDX403281751440000";
COMMIT WORK ;
-- RECOMMENDED EXISTING INDEXES
-- ============================
-- ===========================
--
11 solutions were evaluated by the advisor
DB2 Workload Performance Advisor tool is finished.
--------------------------------------------------------------
--監視器表函式 MON_
db2 "select substr(funcname,1,50) as mon_function from syscat.functions
where funcname like 'MON_GET_%' "
MON_GET_ACTIVITY_DETAILS
MON_GET_APPLICATION_HANDLE
MON_GET_APPLICATION_ID
MON_GET_APPL_LOCKWAIT
MON_GET_BUFFERPOOL
MON_GET_CONNECTION
MON_GET_CONNECTION_DETAILS
MON_GET_CONTAINER
MON_GET_EXTENT_MOVEMENT_STATUS
MON_GET_FCM
MON_GET_FCM_CONNECTION_LIST
MON_GET_INDEX
MON_GET_LOCKS
MON_GET_MEMORY_POOL
MON_GET_MEMORY_SET
MON_GET_PKG_CACHE_STMT
MON_GET_PKG_CACHE_STMT_DETAILS
MON_GET_SERVICE_SUBCLASS
MON_GET_SERVICE_SUBCLASS_DETAILS
MON_GET_TABLE
MON_GET_TABLESPACE
MON_GET_UNIT_OF_WORK
MON_GET_UNIT_OF_WORK_DETAILS
MON_GET_WORKLOAD
MON_GET_WORKLOAD_DETAILS
--最消耗CPU的前10個動態SQL
-- 表函式第一個引數: D 動態;S 靜態; NULL 不區分
db2 "select varchar(stmt_text,200) as statment,
num_exec_with_metrics as numExec,
total_cpu_time,
total_cpu_time/num_exec_with_metrics as avg_cpu_time
from table( mon_get_pkg_cache_stmt('D',NULL,NULL,-2)) AS T
where t.num_exec_with_metrics <> 0
order by avg_cpu_time desc
fetch first 10 rows only
"
----------------------------------------------------------------------------------
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22661144/viewspace-1477176/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- db2 事件監視器型別DB2事件型別
- db2死鎖監視器的使用(好用)DB2
- DB2_使用表函式獲取健康監視器快照DB2函式
- DB2多次抓取快照指令碼DB2指令碼
- DB2監控DB2
- 效能監視器- Performance MonitorORM
- SQL SERVER 效能監視器SQLServer
- Java的物件監視器Java物件
- synchronized的monitor監視器synchronized
- linux 資源監視器Linux
- kvm虛擬機器快照虛擬機
- db2 常見監控DB2
- DB2 鎖的監控DB2
- (轉)Windows 效能監視器工具-perfmonWindows
- Flink CDC 2.3 釋出,持續最佳化效能,更多聯結器支援增量快照,新增 Db2 支援DB2
- 資料庫監視器(SQL Server Profilter)資料庫SQLServerFilter
- 啟動資料庫映象監視器資料庫
- DB2_使用事件監視器DB2事件
- 編寫程式/執行緒監視器執行緒
- 2 Day DBA-檢視監聽器配置-練習:使用Database Control檢視監聽器資訊Database
- db2檢視錶大小DB2
- Hyper-V 3 虛擬機器快照之三 應用和刪除快照虛擬機
- Stats for mac - 選單欄系統監視器Mac
- 自動部署SQLTrace和Windows效能監視器SQLWindows
- Windows7資源監視器在哪裡Windows
- windows 事件監視器資訊查詢/寫入Windows事件
- web伺服器效能評估和監視Web伺服器
- DB2日常監控指令碼DB2指令碼
- 監控DB2資料庫指令碼DB2資料庫指令碼
- DB2 snapshot 管理檢視DB2
- DB2 鎖表情況檢視DB2
- 檢視DB2表結構DB2
- .NET必知的EventCounters效能指標監視器指標
- 專業系統監視器:System Dashboard Pro for MacMac
- DB2傻瓜1000問(十)10、DB2資料庫監控部分DB2資料庫
- db2常用動態效能檢視DB2
- db2檢視執行計劃DB2
- DB2檢視鎖等待的SQLDB2SQL