DB2 Version 9.7 for Linux, UNIX, and Windows

SNAPSWITCHES administrative view and SNAP_GET_SWITCHES table function - Retrieve database snapshot switch state information

The SNAPSWITCHES administrative view and the SNAP_GET_SWITCHES table function return information about the database snapshot switch state.

SNAPSWITCHES administrative view

This view provides the data equivalent to the GET DBM MONITOR SWITCHES CLP command.

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 SNAPSWITCHES administrative view
  • CONTROL privilege on the SNAPSWITCHES administrative view
  • DATAACCESS authority
In addition, one of the following privileges or authorities is also required:
  • EXECUTE privilege on the SNAP_GET_SWITCHES table function
  • DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
  • SYSMON
  • SYSCTRL
  • SYSMAINT
  • SYSADM

Example

Retrieve DBM monitor switches state information for all database partitions.
SELECT UOW_SW_STATE, STATEMENT_SW_STATE, TABLE_SW_STATE, BUFFPOOL_SW_STATE, 
   LOCK_SW_STATE, SORT_SW_STATE, TIMESTAMP_SW_STATE, 
   DBPARTITIONNUM FROM SYSIBMADM.SNAPSWITCHES
TThe following example is a sample output from this query.
UOW_SW_STATE STATEMENT_SW_STATE TABLE_SW_STATE BUFFPOOL_SW_STATE ...
------------ ------------------ -------------- ----------------- ...
           0                  0              0                 0 ...
           0                  0              0                 0 ...
           0                  0              0                 0 ...
                                                                 ...
  3 record selected.                                   
Output from this query (continued).
... LOCK_SW_STATE SORT_SW_STATE TIMESTAMP_SW_STATE DBPARTITIONNUM
... ------------- ------------- ------------------ --------------
...             1             0                  1              0
...             1             0                  1              1
...             1             0                  1              2

SNAP_GET_SWITCHES table function

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

This table function provides the data equivalent to the GET DBM MONITOR SWITCHES CLP command.

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

Syntax

Read syntax diagramSkip visual syntax diagram
>>-SNAP_GET_SWITCHES--(--+----------------+--)-----------------><
                         '-dbpartitionnum-'      

The schema is SYSPROC.

Table function parameter

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 this input option is not used, data will be 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 dbpartitionnum is 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_SWITCHES 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_SWITCHES table function
  • DATAACCESS authority
In addition, to access snapshot monitor data, one of the following authorities is also required:
  • SYSMON
  • SYSCTRL
  • SYSMAINT
  • SYSADM

Examples

Retrieve DBM monitor switches state information for the current database partition.
SELECT UOW_SW_STATE, STATEMENT_SW_STATE, TABLE_SW_STATE, 
   BUFFPOOL_SW_STATE,LOCK_SW_STATE, SORT_SW_STATE, TIMESTAMP_SW_STATE 
   FROM TABLE(SNAP_GET_SWITCHES(-1)) AS T
The following example is a sample output from this query.
UOW_SW_STATE STATEMENT_SW_STATE TABLE_SW_STATE...
------------ ------------------ --------------...
           1                  1              1...
                                              ...
1 record(s) selected.                         ...
Output from this query (continued).
... BUFFPOOL_SW_STATE LOCK_SW_STATE SORT_SW_STATE TIMESTAMP_SW_STATE  
... ----------------- ------------- ------------- ------------------  
...                 1             1             0                  1  

Information returned

Table 1. Information returned by the SNAPSWITCHES administrative view and the SNAP_GET_SWITCHES table function
Column name Data type Description
SNAPSHOT_TIMESTAMP TIMESTAMP snapshot_timestamp - Snapshot timestamp monitor element
UOW_SW_STATE SMALLINT State of the unit of work monitor recording switch (0 or 1).
UOW_SW_TIME TIMESTAMP If the unit of work monitor recording switch is on, the date and time that this switch was turned on.
STATEMENT_SW_STATE SMALLINT State of the SQL statement monitor recording switch (0 or 1).
STATEMENT_SW_TIME TIMESTAMP If the SQL statement monitor recording switch is on, the date and time that this switch was turned on.
TABLE_SW_STATE SMALLINT State of the table activity monitor recording switch (0 or 1).
TABLE_SW_TIME TIMESTAMP If the table activity monitor recording switch is on, the date and time that this switch was turned on.
BUFFPOOL_SW_STATE SMALLINT State of the buffer pool activity monitor recording switch (0 or 1).
BUFFPOOL_SW_TIME TIMESTAMP If the buffer pool activity monitor recording switch is on, the date and time that this switch was turned on.
LOCK_SW_STATE SMALLINT State of the lock monitor recording switch (0 or 1).
LOCK_SW_TIME TIMESTAMP If the lock monitor recording switch is on, the date and time that this switch was turned on.
SORT_SW_STATE SMALLINT State of the sorting monitor recording switch (0 or 1).
SORT_SW_TIME TIMESTAMP If the sorting monitor recording switch is on, the date and time that this switch was turned on.
TIMESTAMP_SW_STATE SMALLINT State of the timestamp monitor recording switch (0 or 1)
TIMESTAMP_SW_TIME TIMESTAMP If the timestamp monitor recording switch is on, the date and time that this switch was turned on.
DBPARTITIONNUM SMALLINT The database partition from which the data was retrieved for this row.