DSN_STATEMENT_CACHE_TABLE

The statement cache table, DSN_STATEMENT_CACHE_TABLE, contains information about the SQL statements in the statement cache, information captured as the results of an EXPLAIN STATEMENT CACHE ALL statement.

Begin program-specific programming interface information.
Recommendation: Do not manually insert data into system-maintained EXPLAIN tables, and use care when deleting obsolete EXPLAIN table data. The data is intended to be manipulated only by the Db2 EXPLAIN function and optimization tools. Certain optimization tools depend on instances of the various EXPLAIN tables. Be careful not to delete data from or drop instances EXPLAIN tables that are created for these tools.

Qualifiers

Your subsystem or data sharing group can contain multiple instances of these tables that are qualified by user ID. These tables are populated with statement cost information when you issue the EXPLAIN statement or bind. They are also populated when you specify EXPLAIN(YES) or EXPLAIN(ONLY) in a BIND or REBIND command. SQL optimization tools might also create EXPLAIN tables that are qualified by a user ID. You can find the SQL statement for creating an instance of these tables in member DSNTESC of the SDSNSAMP library.

Sample CREATE TABLE statement

You can find a sample CREATE TABLE statement for each EXPLAIN table in member DSNTESC of the prefix.SDSNSAMP library. You can call the ADMIN_EXPLAIN_MAINT stored procedure to create EXPLAIN tables, upgrade them to the format for the current Db2 release, or complete other maintenance tasks. See ADMIN_EXPLAIN_MAINT stored procedure for information about using the action input parameter to request each of these tasks.

Column descriptions

The following table shows the descriptions of the columns in DSN_STATEMENT_CACHE_TABLE.

Table 1. Descriptions of columns in DSN_STATEMENT_CACHE_TABLE
Column name Data Type Description
STMT_ID INTEGER NOT NULL The statement ID; this value is the EDM unique token for the statement.
STMT_TOKEN VARCHAR(240) The statement token; you provide this value as an identification string.
COLLID VARCHAR(128) NOT NULL The collection ID:
'DSNEXPLAINMODEYES'
The row originates from an application that specifies YES for the value of the CURRENT EXPLAIN MODE special register.
'DSNEXPLAINMODEEXPLAIN'
The row originates from an application that specifies EXPLAIN for the value of the CURRENT EXPLAIN MODE special register.
PROGRAM_NAME VARCHAR(128) NOT NULL The name of the package that performed the initial PREPARE for the statement.
INV_DROPALT CHAR(1) NOT NULL This column is not used.
INV_REVOKE CHAR(1) NOT NULL This column is not used.
INV_LRU CHAR(1) NOT NULL This column is not used.
INV_RUNSTATS CHAR(1) NOT NULL This column is not used.
CACHED_TS TIMESTAMP NOT NULL The timestamp when the statement was stored in the dynamic statement cache.3
USERS INTEGER NOT NULL The number of current users of the statement. This number indicates the users that have prepared or run the statement during their current unit of work. 1,3
COPIES INTEGER NOT NULL The number of copies of the statement that are owned by all threads in the system. 1,3
LINES INTEGER NOT NULL The precompiler line number from the initial PREPARE of the statement. 1
PRIMAUTH VARCHAR(128) NOT NULL The primary authorization ID that did the initial PREPARE of the statement.
CURSQLID VARCHAR(128) NOT NULL The CURRENT SQLID that did the initial PREPARE of the statement.
BIND_QUALIFIER VARCHAR(128) NOT NULL The BIND qualifier. For unqualified table names, this is the object qualifier.
BIND_ISO CHAR(2) NOT NULL The value of the ISOLATION BIND option that is in effect for this statement. The value will be one of the following values:
'UR'
Uncommitted read
'CS'
Cursor stability
'RS'
Read stability
'RR'
Repeatable read
BIND_CDATA CHAR(1) NOT NULL The value of the CURRENTDATA BIND option that is in effect for this statement. The value will be one of the following values:
'Y'
CURRENTDATA(YES)
'N'
CURRENTDATA(NO)
BIND_DYNRL CHAR(1) NOT NULL The value of the DYNAMICRULES BIND option that is in effect for this statement. The value will be one of the following values:
'B'
DYNAMICRULE(BIND)
'R'
DYNAMICRULES(RUN)
BIND_DEGRE CHAR(1) NOT NULL The value of the CURRENT DEGREE special register that is in effect for this statement. The value will be one of the following values:
'A'
CURRENT DEGREE = ANY
'1'
CURRENT DEGREE = 1
BIND_SQLRL CHAR(1) NOT NULL The value of the CURRENT RULES special register that is in effect for this statement. The value will be one of the following values:
'D'
CURRENT RULES = DB2
'S'
CURRENT RULES = SQL
BIND_CHOLD CHAR(1) NOT NULL The value of the WITH HOLD attribute of the PREPARE for this statement. The value will be one of the following values:
'Y'
Initial PREPARE specified WITH HOLD
'N'
Initial PREPARE specified WITHOUT HOLD
STAT_TS TIMESTAMP NOT NULL Timestamp of the statistics. This is the timestamp when IFCID 318 is started. 2
STAT_EXEC INTEGER NOT NULL This column is deprecated. Use STAT_EXECB instead.
STAT_GPAG INTEGER NOT NULL This column is deprecated. Use STAT_GPAGB instead. 1
STAT_SYNR INTEGER NOT NULL This column is deprecated. Use STAT_SYNRB instead. 1
STAT_WRIT INTEGER NOT NULL This column is deprecated. Use STAT_WRITB instead. 1
STAT_EROW INTEGER NOT NULL This column is deprecated. Use STAT_EROWB instead. 1
STAT_PROW INTEGER NOT NULL This column is deprecated. Use STAT_PROWB instead. 1
STAT_SORT INTEGER NOT NULL This column is deprecated. Use STAT_SORTB instead. 1
STAT_INDX INTEGER NOT NULL This column is deprecated. Use STAT_INDXB instead.
STAT_RSCN INTEGER NOT NULL This column is deprecated. Use STAT_RSCNB instead.
STAT_PGRP INTEGER NOT NULL This column is deprecated. Use STAT_PGRPB instead.
STAT_ELAP FLOAT NOT NULL The accumulated elapsed time that is used for the statement. 2
STAT_CPU FLOAT NOT NULL The accumulated CPU time that is used for the statement. 2
STAT_SUS_SYNIO FLOAT NOT NULL The accumulated wait time for synchronous I/O operations for the statement. 2
STAT_SUS_LOCK FLOAT NOT NULL The accumulated wait time for lock requests for the statement. 2
STAT_SUS_SWIT FLOAT NOT NULL The accumulated wait time for synchronous execution unit switch for the statement. 2
STAT_SUS_GLCK FLOAT NOT NULL The accumulated wait time for global parent L-locks for this statement. 2
STAT_SUS_OTHR FLOAT NOT NULL The accumulated wait time for read activity that is done by another thread. 2
STAT_SUS_OTHW FLOAT NOT NULL The accumulated wait time for write activity done by another thread. 2
STAT_RIDLIMT INTEGER NOT NULL This column is deprecated. Use STAT_SORTB instead.
STAT_RIDSTOR INTEGER NOT NULL This column is deprecated. Use STAT_SORTB instead.
EXPLAIN_TS TIMESTAMP NOT NULL The timestamp for when the statement cache table is populated.
SCHEMA VARCHAR(128) NOT NULL The value of the CURRENT SCHEMA special register.
STMT_TEXT CLOB(2M) NOT NULL The statement that is being explained.
STMT_ROWID ROWID NOT NULL GENERATED ALWAYS The ROWID of the statement.
BIND_RO_TYPE CHAR(1) NOT NULL WITH DEFAULT The current specification of the REOPT option for the statement3:
'N'
REOPT(NONE) or its equivalent
'1'
REOPT(ONCE) or its equivalent
'A'
REOPT(AUTO) or its equivalent
'O'
The current plan is deemed optimal and there is no need for REOPT(AUTO)
BIND_RA_TOT INTEGER NOT NULL WITH DEFAULT The total number of REBIND commands that have been issued for the dynamic statement because of the REOPT(AUTO) option.1,3
GROUP_MEMBER VARCHAR(24) NOT NULL WITH DEFAULT The member name of the Db2 that executed EXPLAIN. The column is blank if the Db2 subsystem was not in a data sharing environment when EXPLAIN was executed.
STAT_EXECB BIGINT NOT NULL WITH DEFAULT The number of times this statement has been run. For a statement with a cursor, this is the number of OPENs.2
STAT_GPAGB BIGINT NOT NULL WITH DEFAULT The number of getpage operations that are performed for the statement. 2
STAT_SYNRB BIGINT NOT NULL WITH DEFAULT The number of synchronous buffer reads that are performed for the statement. 2
STAT_WRITB BIGINT NOT NULL WITH DEFAULT The number of buffer write operations that are performed for the statement. 2
STAT_EROWB BIGINT NOT NULL WITH DEFAULT The number of rows that are examined for the statement. 2
STAT_PROWB BIGINT NOT NULL WITH DEFAULT The number of rows that are processed for the statement. 2
STAT_SORTB BIGINT NOT NULL WITH DEFAULT The number of sorts that are performed for the statement.2
STAT_INDXB BIGINT NOT NULL WITH DEFAULT The number of index scans that are performed for the statement.2
STAT_RSCNB BIGINT NOT NULL WITH DEFAULT The number of table space scans that are performed for the statement.2
STAT_PGRPB BIGINT NOT NULL WITH DEFAULT The number of parallel groups that are created for the statement.2
STAT_RIDLIMTB BIGINT NOT NULL WITH DEFAULT The number of times a RID list was not used because the number of RIDs would have exceeded Db2 limits.2
STAT_RIDSTORB BIGINT NOT NULL WITH DEFAULT The number of times a RID list was not used because there is not enough storage available to hold the list of RIDs.2
LITERAL_REPL CHAR(1) NOT NULL WITH DEFAULT Identifies cached statements where the literal values are replaced by the '&' symbol:3
'R'
The statement is prepared with CONCENTRATE STATEMENTS WITH LITERALS behavior and the literal constants in the statement have been replaced with '&' .
'D'
This statement is a duplicate statement instance with different literal reusability criteria.
blank
Literal values are not replaced.
STAT_SUS_LATCH FLOAT NOT NULL WITH DEFAULT The accumulated wait time for latch requests for the statement.
STAT_SUS_PLATCH FLOAT NOT NULL WITH DEFAULT The accumulated wait time for page latch requests for the statement.
STAT_SUS_DRAIN FLOAT NOT NULL WITH DEFAULT The accumulated wait time for drain lock requests for the statement.
STAT_SUS_CLAIM FLOAT NOT NULL WITH DEFAULT The accumulated wait time for claim count requests for the statement.
STAT_SUS_LOG FLOAT NOT NULL WITH DEFAULT The accumulated wait time for log writer requests for the statement.
EXPANSION_REASON CHAR(2) NOT NULL WITH DEFAULT
This column applies only to statements that reference archive tables or temporal tables. For other statements, this column is blank.

Indicates the effect of the CURRENT TEMPORAL BUSINESS_TIME special register, the CURRENT TEMPORAL SYSTEM_TIME special register, and the SYSIBMADM.GET_ARCHIVE built-in global variable. These items are controlled by the BUSTIMESENSITIVE, SYSTIMESENSITIVE, and ARCHIVESENSITIVE bind options.

Db2 implicitly adds certain syntax to the query if one of the following conditions are true:
  • The SYSIBMADM.GET_ARCHIVE global variable is set to Y and the ARCHIVESENSITIVE bind option is set to YES
  • The CURRENT TEMPORAL BUSINESS_TIME special register is not null and the BUSTIMESENSITIVE bind option is set to YES
  • The CURRENT TEMPORAL SYSTEM_TIME special register is not null and the SYSTIMESENSITIVE bind option is set to YES
This column can have one of the following values:
'A'
The query contains implicit query transformation as a result of the SYSIBMADM.GET_ARCHIVE built-in global variable.
'B'
The query contains implicit query transformation as a result of the CURRENT TEMPORAL BUSINESS_TIME special register.
'S'
The query contains implicit query transformation as a result of the CURRENT TEMPORAL SYSTEM_TIME special register.
'SB'
The query contains implicit query transformation as a result of the CURRENT TEMPORAL SYSTEM_TIME special register and the CURRENT TEMPORAL BUSINESS_TIME special register.
blank
The query does not contain implicit query transformation.
ACCELERATED CHAR(10) Identifies whether a cached dynamic statement was prepared for acceleration to an accelerator server. Possible values are:
'NO'
The cached statement was not prepared for acceleration. This is the default value.

This value also applies to cached statements under the following conditions:

  • The query acceleration behavior was not specified or was explicitly set to NONE when the dynamic statement was prepared.
  • A query acceleration behavior other than ALL was specified when the dynamic statement was prepared. Db2 did not prepare the statement for acceleration because it did not qualify for acceleration based on the query acceleration behavior that was specified.
'YES'
The cached statement was prepared for acceleration to an accelerator server based on the query acceleration behavior that was specified. If query acceleration behavior is specified when a dynamic statement is prepared, Db2 can consider this cache entry for a possible cache match during the prepare operation of the dynamic statement. If query acceleration behavior is not specified, or is explicitly set to NONE when the statement is prepared, Db2 does not consider this cache entry for a cache match during the prepare operation.
'NEVER'
The cached statement was not prepared for acceleration to an accelerated server, because the statement can never be accelerated.
  • If the query acceleration behavior is set to ENABLE, ENABLE WITH FAILBACK, or ELIGIBLE for the prepare of the statement, Db2 considers this cache entry first as a possible cache match during the prepare operation. This action verifies whether the statement was cached previously as one that can never be accelerated.

(Continued in the following row.)

ACCELERATED (continued)  

(Continued from the previous row.)

'NEVER' (continued)
  • If the query acceleration behavior is set to ALL for the prepare of the statement, Db2 does not consider this cache entry as a possible cache match during the prepare operation.
  • If the query acceleration behavior is not specified, or is explicitly set to NONE for the prepare of the statement, Db2 does not consider this cache entry as a possible cache match during the prepare operation.
'ACCEL_ONLY'
The cached statement was prepared for acceleration to an accelerator. The statement references at least one accelerator-only table and can only be prepared to execute in the accelerator server. If query acceleration behavior is specified when a dynamic statement is prepared, Db2 can consider this cache entry for a possible cache match during the prepare operation of the dynamic statement. If query acceleration behavior is not specified, or is explicitly set to NONE when the statement is prepared, Db2 does not consider this cache entry for a cache match during the prepare operation.

Query acceleration behavior is specified by either the QUERY_ACCELERATION subsystem parameter, the QUERYACCELERATION bind option, or the CURRENT QUERY ACCELERATION special register, and depends on their order of precedence. The order of precedence (lowest to highest) is:

  • The QUERY_ACCELERATION subsystem parameter
  • The QUERYACCELERATION bind option, if specified
  • An explicit SET CURRENT QUERY ACCELERATION statement
STAT_ACC_ELAP BIGINT The accumulated elapsed time for the accelerator.
STAT_ACC_CPU BIGINT The accumulated CPU time for the accelerator.
STAT_ACC_ROW BIGINT The accumulated number of rows that are returned from the accelerator.
STAT_ACC_BYTE BIGINT The accumulated number of bytes that are returned from the accelerator.
STAT_ACC_1ROW BIGINT The time waited for the first row of the query result to be available from the accelerator.
STAT_ACC_DB2 BIGINT The total time the accelerator waited for Db2 to request query results.
STAT_ACC_EXEC BIGINT The accumulated execution time for the accelerator.
STAT_ACC_WAIT BIGINT The accumulated queue wait time for the accelerator.
ACCEL_OFFLOAD_ELIGIBLE CHAR(1)
'NO'
The statement is not eligible for acceleration. This is the default value.
'YES'
The statement is a candidate for acceleration when an accelerator server is available to the Db2 subsystem.
ACCELERATOR_NAME VARCHAR(128) The concatenated name of the accelerator server that processed the query.
PER_STMT_ID BIGINT NOT NULL The statement identifier of the stabilized dynamic SQL statement. This value is set if this entry was stabilized to or loaded from the SYSIBM.SYSDNQRY catalog table
STBLGRP VARCHAR(128 ) NOT NULL The stabilization group name specified in a START DYNQRY command. This value is set if this entry was stabilized to or loaded from the SYSIBM.SYSDNQRY catalog table.
QUERY_HASH CHAR(16) NOT NULL FOR BIT DATA The hash key generated by the statement text.
QUERY_HASH_VERSION INTEGER NOT NULL The version of QUERY_HASH.
STABILIZED CHAR(1) NOT NULL Indicates whether the statement was stabilized.
Start of changeAPPLCOMPATEnd of change Start of changeVARCHAR(10) NOT NULLEnd of change Start of changeThe application compatibility level of a dynamic SQL statement.End of change
CNO BIGINT NOT NULL The command number for the dynamic query capture monitor if applicable. Otherwise 0.
STAT_SUS_CHILDLLOCK FLOAT NOT NULL WITH DEFAULT The accumulated wait time for child L-locks for the statement.
STAT_SUS_OTHERLLOCK FLOAT NOT NULL WITH DEFAULT The accumulated wait time for other L-locks for the statement.
STAT_SUS_PAGESETPLOCK FLOAT NOT NULL WITH DEFAULT The accumulated wait time for global pageset or partition L-locks for the statement.
STAT_SUS_PAGEPLOCK FLOAT NOT NULL WITH DEFAULT The accumulated wait time for page P-locks for the statement.
STAT_SUS_OTHERPLOCK FLOAT NOT NULL WITH DEFAULT The accumulated wait time for other P-locks for the statement.
STAT_SUS_PIPE FLOAT NOT NULL WITH DEFAULT The accumulated wait time for pipe requests for the statement.
STAT_SUS_PQSYNC FLOAT NOT NULL WITH DEFAULT The accumulated waittime for parallel query waits for the statement.
STAT_ACC_TWDP BIGINT The accumulated wait time for the accelerator delay protocol.
STAT_ACC_NWDP BIGINT The accumulated number of statements for which the wait time for the accelerator delay protocol has expired.
STMT_HASHID2 CHAR(8) FOR BIT DATA Used to identify an SQL statement. Based on normalized SQL statement text.
  • Includes certain BIND options for static SQL, and PREPARE attributes for dynamic SQL.
  • Includes COLLID and PACKAGE name for static SQL.
  • Excludes COLLID and PACKAGE name for dynamic SQL.
  • Excludes VERSION name for static SQL.
STMT_HASH2VER INTEGER Used to identify the version of the hash algorithm that is used to compute the STMT_HASHID2 value.
Start of changeAP_PLANIDEnd of change Start of changeCHAR(16) FOR BIT DATAEnd of change Start of changeA unique identifier for BIND or PREPARE optimizations for an SQL statement, in the form of an extended timestamp value.End of change
AP_PLANHASH CHAR(16) FOR BIT DATA Used to identifier an access path based on selected columns of the PLAN_TABLE that contribute to the access path. This value excludes columns that do not affect the access path, such as APPLNAME, PROGNAME, VERSION, and others.
AP_PLANHASHVER INTEGER Used to identify the version of the hash algorithm that is used to compute the AP_PLANHASH value.
CONNECTION_TYPE CHAR(8) Connection type which did the PREPARE or BIND for the statement.
CLIENT_USERID VARCHAR(128) The client user ID name information.
CLIENT_APPLNAME VARCHAR(255) The client application name information.
CLIENT_WRKSTNNAME VARCHAR(255) The client workstation name information.
Start of changeSTAT_ZIIP_CPUEnd of change Start of changeFLOATEnd of change Start of changeAccumulated CPU time that was consumed by execution of SQL on an IBM specialty engine.End of change
Notes:
  1. If the specified value exceeds 2147483647, the column contains the value 2147483647.
  2. Statistics are cumulative, across executions of the same statement, and across threads, if the value of COLLID is DSNDYNAMICSQLCACHE. If the value of COLLID is DSNEXPLAINMODEYES, the values are for a single run of the statement only. If the value of COLLID is DSNEXPLAINMODE EXPLAIN, the values of all statistics columns are 0.
  3. The column is not applicable when the value of the COLLID column is 'DSNEXPLAINMODEYES' or 'DSNEXPLAINMODEEXPLAIN'

End program-specific programming interface information.