DB2 Version 9.7 for Linux, UNIX, and Windows

SNAPSUBSECTION administrative view and SNAP_GET_SUBSECTION table function - Retrieve subsection logical monitor group snapshot information

The SNAPSUBSECTION administrative view and the SNAP_GET_SUBSECTION table function return information about application subsections, namely the subsection logical monitor grouping.

SNAPSUBSECTION administrative view

This administrative view allows you to retrieve subsection logical monitor group snapshot information for the currently connected database.

Used with the SNAPAGENT, SNAPAGENT_MEMORY_POOL, SNAPAPPL, SNAPAPPL_INFO and SNAPSTMT administrative views, the SNAPSUBSECTION administrative view provides information equivalent to the GET SNAPSHOT FOR APPLICATIONS on database-alias CLP command, but retrieves data from all database partitions.

The schema is SYSIBMADM.

Refer to Table 1 for a complete list of information that can be returned.

Authorization

One of the following authorizations is required:
  • SELECT privilege on the SNAPSUBSECTION administrative view
  • CONTROL privilege on the SNAPSUBSECTION administrative view
  • DATAACCESS authority
In addition, one of the following privileges or authorities is also required:
  • EXECUTE privilege on the SNAP_GET_SUBSECTION table function
  • DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
  • SYSMON
  • SYSCTRL
  • SYSMAINT
  • SYSADM

Example

Get status for subsections executing on all database partitions.
SELECT DB_NAME, STMT_TEXT, SS_STATUS, DBPARTITIONNUM 
   FROM SYSIBMADM.SNAPSUBSECTION 
   ORDER BY DB_NAME, SS_STATUS, DBPARTITIONNUM
The following example is a sample output from this query.
DB_NAME     STMT_TEXT                  SS_STATUS     DBPARTITIONNUM
-------...- ----------------------...- ---------...- --------------
SAMPLE      select * from EMPLOYEE     EXEC                       0
SAMPLE      select * from EMPLOYEE     EXEC                       1

SNAP_GET_SUBSECTION table function

The SNAP_GET_SUBSECTION table function returns the same information as the SNAPSUBSECTION administrative view, but allows you to retrieve the information for a specific database on a specific database partition, aggregate of all database partitions or all database partitions.

Refer to Table 1 for a complete list of information that can be returned.

Used with the SNAP_GET_AGENT, SNAP_GET_AGENT_MEMORY_POOL, SNAP_GET_APPL_V95, SNAP_GET_APPL_INFO_V95 and SNAP_GET_STMT table functions, the SNAP_GET_SUBSECTION table function provides information equivalent to the GET SNAPSHOT FOR ALL APPLICATIONS CLP command, but retrieves data from all database partitions.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-SNAP_GET_SUBSECTION--(--dbname--+------------------+--)-----><
                                   '-, dbpartitionnum-'      

The schema is SYSPROC.

Table function parameters

dbname
An input argument of type VARCHAR(128) that specifies a valid database name in the same instance as the currently connected database. Specify a database name that has a directory entry type of either "Indirect" or "Home", as returned by the LIST DATABASE DIRECTORY command. Specify an empty string to take the snapshot from the currently connected database. Specify a NULL value to take the snapshot from all databases within the same instance as the currently connected database.
dbpartitionnum
An optional input argument of type INTEGER that specifies a valid database partition number. Specify -1 for the current database partition, or -2 for an aggregate of all active database partitions. If dbname is not set to NULL and dbpartitionnum is set to NULL, -1 is set implicitly for dbpartitionnum. If this input option is not used, that is, only dbname is provided, data is returned from all active database partitions. An active database partition is a partition where the database is available for connection and use by applications.

If both dbname and dbpartitionnum are set to NULL, an attempt is made to read data from the file created by SNAP_WRITE_FILE procedure. Note that this file could have been created at any time, which means that the data might not be current. If a file with the corresponding snapshot API request type does not exist, then the SNAP_GET_SUBSECTION table function takes a snapshot for the currently connected database and database partition number.

Authorization

One of the following authorizations is required:
  • EXECUTE privilege on the SNAP_GET_SUBSECTION table function
  • DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
  • SYSMON
  • SYSCTRL
  • SYSMAINT
  • SYSADM

Example

Get status for subsections executing on all database partitions.
SELECT DB_NAME, STMT_TEXT, SS_STATUS, DBPARTITIONNUM 
   FROM TABLE(SYSPROC.SNAP_GET_SUBSECTION( '', 0 )) as T 
   ORDER BY DB_NAME, SS_STATUS, DBPARTITIONNUM
The following example is a sample output from this query.
DB_NAME     STMT_TEXT                  SS_STATUS     DBPARTITIONNUM
-------...- ----------------------...- ---------...- --------------
SAMPLE      select * from EMPLOYEE     EXEC                       0
SAMPLE      select * from EMPLOYEE     EXEC                       1

Information returned

Table 1. Information returned by the SNAPSUBSECTION administrative view and the SNAP_GET_SUBSECTION table function
Column name Data type Description or corresponding monitor element
SNAPSHOT_TIMESTAMP TIMESTAMP snapshot_timestamp - Snapshot timestamp monitor element
DB_NAME VARCHAR(128) db_name - Database name
STMT_TEXT CLOB(16 M) stmt_text - SQL statement text
SS_EXEC_TIME BIGINT ss_exec_time - Subsection execution elapsed time
TQ_TOT_SEND_SPILLS BIGINT tq_tot_send_spills - Total number of table queue buffers overflowed
TQ_CUR_SEND_SPILLS BIGINT tq_cur_send_spills - Current number of table queue buffers overflowed
TQ_MAX_SEND_SPILLS BIGINT tq_max_send_spills - Maximum number of table queue buffers overflows
TQ_ROWS_READ BIGINT tq_rows_read - Number of rows read from table queues
TQ_ROWS_WRITTEN BIGINT tq_rows_written - Number of rows written to table queues
ROWS_READ BIGINT rows_read - Rows read
ROWS_WRITTEN BIGINT rows_written - Rows written
SS_USR_CPU_TIME_S BIGINT ss_usr_cpu_time - User CPU time used by subsection (in seconds)*
SS_USR_CPU_TIME_MS BIGINT ss_usr_cpu_time - User CPU time used by subsection (fractional, in microseconds)*
SS_SYS_CPU_TIME_S BIGINT ss_sys_cpu_time - System CPU time used by subsection (in seconds)*
SS_SYS_CPU_TIME_MS BIGINT ss_sys_cpu_time - System CPU time used by subsection (fractional, in microseconds)*
SS_NUMBER INTEGER ss_number - Subsection number
SS_STATUS VARCHAR(20) ss_status - Subsection status . This interface returns a text identifier based on defines in sqlmon.h and is one of:
  • EXEC
  • TQ_WAIT_TO_RCV
  • TQ_WAIT_TO_SEND
  • COMPLETED
SS_NODE_NUMBER SMALLINT ss_node_number - Subsection node number
TQ_NODE_WAITED_FOR SMALLINT tq_node_waited_for - Waited for node on a table queue
TQ_WAIT_FOR_ANY INTEGER tq_wait_for_any - Waiting for any node to send on a table queue
TQ_ID_WAITING_ON INTEGER tq_id_waiting_on - Waited on node on a table queue
DBPARTITIONNUM SMALLINT The database partition from which the data was retrieved for this row.
* To calculate the total time spent for the monitor element that this column is based on, you must add the full seconds reported in the column for this monitor element that ends with _S to the fractional seconds reported in the column for this monitor element that ends with _MS, using the following formula: (monitor-element-name_S × 1,000,000 + monitor-element-name_MS) ÷ 1,000,000. For example, (ELAPSED_EXEC_TIME_S × 1,000,000 + ELAPSED_EXEC_TIME_MS) ÷ 1,000,000.