MON_GET_TABLE table function - get table metrics
The MON_GET_TABLE table function returns monitor metrics for one or more tables.
Syntax
The schema is SYSPROC.
Table function parameters
- tabschema
- An input argument of type VARCHAR(128) that specifies a valid table schema name in the currently connected database when calling this function. If the argument is null or an empty string, metrics are retrieved for all tables in all schemas in the database. If the argument is specified, metrics are only returned for tables in the specified schema.
- tabname
- An input argument of type VARCHAR(128) that specifies a valid table name in the currently connected database when calling this function. If the argument is null or an empty string, metrics are retrieved for all the tables in the database.
- member
- An input argument of type INTEGER that specifies a valid member in the same instance as the currently connected database when calling this function. Specify -1 for the current database member, or -2 for all active database members. If the NULL value is specified, -1 is set implicitly.
Authorization
- EXECUTE privilege on the routine
- DATAACCESS authority
- DBADM authority
- SQLADM authority
Default PUBLIC privilege
None
Information returned
Usage notes
The MON_GET_TABLE table function returns one row of data per database table and per database member. If range-partitioned tables are being used, one row is returned for each table partition per database member. No aggregation across database members is performed. However, aggregation can be achieved through SQL queries as shown in the example.
Rows are returned only for tables accessed since the database was activated.
The metrics returned by this function are collected at two levels. Some metrics are always collected, while the collection of other metrics is controlled at the database level using the mon_obj_metrics configuration parameter. Refer to the descriptions provided in the preceding table to determine if any settings must be active for data to be collected for a particular metric.
Examples
- List the activity on all tables accessed since the database was
activated, aggregated across all database members, ordered by highest
number of reads.
SELECT varchar(tabschema,20) as tabschema, varchar(tabname,20) as tabname, sum(rows_read) as total_rows_read, sum(rows_inserted) as total_rows_inserted, sum(rows_updated) as total_rows_updated, sum(rows_deleted) as total_rows_deleted FROM TABLE(MON_GET_TABLE('','',-2)) AS t GROUP BY tabschema, tabname ORDER BY total_rows_read DESC
The following is an example of output from this query.
TABSCHEMA TABNAME TOTAL_ROWS_READ ... -------------------- -------------------- -------------------- ... SYSIBM SYSHISTO 113 ... SYSIBM SYSWORKL 22 ... SYSIBM SYSROUTI 13 ... SYSIBM SYSSERVI 13 ... SYSIBM SYSTHRES 6 ... SYSIBM SYSTABLE 3 ... SYSIBM SYSCONTE 2 ... SYSIBM SYSDBAUT 2 ... SYSIBM SYSEVENT 2 ... SYSIBM SYSPLAN 1 ... SYSIBM SYSSURRO 1 ... SYSIBM SYSVERSI 1 ... SYSIBM SYSXMLST 1 ... SYSIBM SYSAUDIT 0 ... SYSIBM SYSROLEA 0 ... SYSIBM SYSROLES 0 ... SYSIBM SYSTASKS 0 ... SYSIBM SYSWORKA 0 ... SYSIBM SYSXMLPA 0 ... 19 record(s) selected.
Output for query (continued).
... TOTAL_ROWS_INSERTED TOTAL_ROWS_UPDATED TOTAL_ROWS_DELETED ... -------------------- -------------------- -------------------- ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0 ... 0 0 0
- Get
the explicit hierarchical locking state for tables in the schema JOE
from member 1:
This query returns the following output:SELECT SUBSTR(TABNAME,1,8) AS TABNAME, MEMBER, DATA_SHARING_STATE AS DS_STATE, DATA_SHARING_REMOTE_LOCKWAIT_COUNT AS DSRL_COUNT, DATA_SHARING_REMOTE_LOCKWAIT_TIME AS DSRL_TIME FROM TABLE(MON_GET_TABLE('JOE','',1))
This output shows that table T1 is currently in a "NOT_SHARED" state and has never been forced out of this state during the current database activation. Table T3 has never entered a "NOT_SHARED" state. Table T2 has been in a "NOT_SHARED" state twice and has had to exit both times.TABNAME MEMBER DS_STATE DSRL_COUNT DSRL_TIME -------- ------ ------------------- -------------------- -------------------- T1 1 NOT_SHARED 0 0 T2 1 SHARED 2 21844 T3 1 SHARED 0 0