Personal tools
You are here: Home DB2 DB2 UDB v9 Monitoring performance with SQL -Lock chain
Navigation
Log in


Forgot your password?
 
Document Actions

Monitoring performance with SQL -Lock chain

query that can be used to list the lock chains for applications that are currently in a lock wait

 

 

This shows a query that can be used to list the lock chains for applications that are currently in a lock wait. Applications that are not in a lock wait will not be listed because the SQL join insures that only locks with a matching holder will be returned.

 

db2 "select substr(ai_h.primary_auth_id,1,10) as Holder_APP_ID, \
ai_h.agent_id as HOLDER_APP_HANDLE, substr(lw.authid,1,10) as Waiter_APP_ID, \
lw.agent_id as WAITER_APP_HANDLE, lw.lock_mode , lw.lock_object_type , \
substr(lw.tabname,1,10) as TabName,substr(lw.tabschema,1,10) as Schema, \
timestampdiff(2,char(lw.snapshot_timestamp-lw.lock_wait_start_time)) as waiting_s \
 from sysibmadm.lockwaits lw , sysibmadm.snapappl_info \
ai_h where lw.agent_id_holding_lk = ai_h.agent_id"


Output

Hold_App_NAME    Holder_APP_HANDLE     Wait_App_NAME      Waiter_APP_HANDLE LOCK_MODE LOCK_OBJECT_TYPE TabName Schema waiting_s
------------------------    ---------------------------------      -------------------------      --------------------------------     ------------------------- -----------------------   ----------   -------
db2bp                                               461                              db2bp                                        476                   X         TABLE_LOCK    HIST1    CLPM     1368

 

 

 This query shows any lock chains that currently exist. It shows the lock holder, the application/user waiting on the lock, as well as the object locked and the length of time the waiter has been waiting. It is not abnormal to see lock wait chains. What is abnormal is to see lengthy waiting times. If you see long waits, you should look at what the holding application is doing (what SQL statement and what the application status is) to determine if the application is well tuned.

Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls