Wednesday, March 12, 2008

SNAPSHOT_DYN_SQL and decimal() function

select NUM_EXECUTIONS,(decimal(TOTAL_EXEC_TIME)/NUM_EXECUTIONS) as AVERAGEEXECTIME,STMT_TEXT from table(SNAPSHOT_DYN_SQL('',-1)) as SNAPDYN where NUM_EXECUTIONS > 0 order by AVERAGEEXECTIME desc fetch first 8 rows only".

For any queries like the one listed here on snapshot table function snapshot_dyn_sql,decimal() function can be used to get the time in subseconds.If you do not use decimal function, it would display the time in seconds only and a 0 would appear if your query response time is below a second

Thursday, March 6, 2008

Viewing lockchains

If you have a lock wait situation you can use the following stored procedure to view the lockchains :

db2 call sysproc.am_get_lock_chns(15,?)

15 in the above call statement stands for application handle.Output would look like 15 --> 11 --> 7 It implies that 15 is waiting for 11 which inturn is waiting for 7