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


Forgot your password?
 
Document Actions

Monitoring performance with SQL -Long running SQL

This query uses the administrative view, SYSIBMADM.LONG_RUNNING_SQL,
which returns the longest running SQL statements in the currently
connected database.

db2 "select substr(appl_name,1,15) as Appl_name ,agent_id as APPL_HANDLE, elapsed_time_min as \
Elapsed_Min , appl_status as Status, substr(authid,1,10) as auth_id , \
substr(inbound_comm_address,1,15) as IP_Address, \
substr(stmt_text,1,30) as SQL_Statement from \
sysibmadm.long_running_sql order by 2 desc"


APPL_NAME APPL_HANDLE       ELAPSED_MIN                 STATUS                 AUTH_ID    IP_ADDRESS      SQL_STATEMENT
--------------- -      -------------          --------------- ---------------------- ---------- --------------- -------------------               -----------
pmrt                                12                  -             CONNECTED                  INFOBT   140.22.53.17 59 -
db2evmg_DIG                 45                 -            CONNECTED                        DB2        -                                          -
db2taskd                         23                 -           CONNECTED                        DB2        -                                           -
db2stmm                         12                 -            CONNECTED                       DB2        -                                           -
db2bp                             34                  0              UOWEXEC                      ISNT1       *LOCAL.udb1     select substr(appl_name,1,15)
pmrt                                25                  0              UOWWAIT                    INFOBT   140.22.53.17 59                       -


The view joins several application snapshot functions and calculates the elapsed time for
each application. This can be used to find the current SQL statements for the longest
running applications.

You can also see the status of the query. If  the statement is listed as executing a
long time and waiting on a lock, you may want to dig deeper by looking at some
of the locking snapshots. If the status is waiting on User, this means that DB2 is
not doing anything, but rather is waiting for the application to do something
(like issue the next FETCH or submit the next SQL statement).

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





Polls