Search code examples
db2-luw

Difference between TOTAL_CONNECTIONS in MON_GET_INSTANCE and REM_CONS_IN and LOCAL_CONS in SYSIBMADM.SNAPDBM in IBM DB2


I am going to calculate current number of connection to IBM DB2 there is two table that include statistics of connections. one of them is MON_GET_INSTANCE that include TOTAL_CONNECTIONS: "Current number of connections to database and is collected from the MON_GET_INSTANCE." the other is SYSIBMADM.SNAPDBM that has LOCAL_CONS and REM_CONS_IN. The sum of REM_CONS_IN and LOCAL_CONS show the number of connection to the database. As I checked these two approach to calculate number of connections are very different. what is the difference of TOTAL_CONNECTIONS in MON_GET_INSTANCE and has LOCAL_CONS and REM_CONS_IN in SYSIBMADM.SNAPDBM?

I run SELECT (LOCAL_CONS + REM_CONS_IN) As TOTAL_CONS FROM SYSIBMADM.SNAPDBM; with result 23 and at the same time i run select TOTAL_CONNECTIONS from Table(MON_GET_INSTANCE(-2)); that result 1. they are very different.


Solution

  • The MON_GET_INSTANCE function doesn't show system applications, while the SNAPDBM one does.
    If you want to get total connections count from the MON_* family, you may sum up the result of the following queries to each of your local databases. The last parameter (1) instructs the function to show system applications as well.

    SELECT COUNT (1) 
    FROM TABLE (MON_GET_CONNECTION (NULL, -2, 1))
    

    Note, that there is no corresponding parameter for the MON_GET_INSTANCE function.