DB2 11 for z/os Profiles Overview The New ZParms and MORE! Paul Bartak, IBM DB2 Advisor paul.bartak@us.ibm.com 1 Profiles are gaining momentum, flexibility, and are evolving A profile is a set of criteria that identifies a particular context on a DB2 subsystem such as Threads, Connections (System Resources), or SQL statements that have particular attributes. Profiles incorporate: Monitoring remote threads and remote connections (TCP/IP) Optimization System Parameters for SQL statements Modeling your production environment in test for SQL EXPLAIN Setting thresholds for Query Acceleration IDAA Setting the value of a special register Knowledge Center Topic 2 1
Profile tables Following are a complete set of PROFILE objects: SYSIBM.DSN_PROFILE_TABLE SYSIBM.DSN_PROFILE_HISTORY SYSIBM.DSN_PROFILE_ATTRIBUTES SYSIBM.DSN_PROFILE_ATTRIBUTES_HISTORY DSNTIJSG creates the profile tables Three supporting indices: SYSIBM.DSN_PROFILE_TABLE_IX_ALL SYSIBM.DSN_PROFILE_TABLE_IX2_ALL SYSIBM.DSN_PROFILE_ATTRIBUTES_IX_ALL In DSNOPTDB.DSNOPTTS 3 Profile Scope, Context and the Action SYSIBM.DSN_PROFILE_TABLE Defines the context Profile and filtering (ie. LOCATION, PRDID, AUTHID, etc.) Only certain combinations are allowed PROFILEID defaults to identity column value The PROFILE_ENABLED column indicates whether DB2 activates the profile when you start monitoring Defaults to Y PROFILE_TIMESTAMP defaults to CURRENT SYSIBM.DSN_PROFILE_ATTRIBUTES table Controls the actions Defines attributes (ie. MONITOR CONNECTIONS, MONITOR THREADS, and MONITOR IDLE THREADS, etc.) One or more attributes rows are required PROFILEID is foreign key to DSN_PROFILE_TABLE (delete cascade) ATTRIBUTE_TIMESTAMP defaults to CURRENT 4 2
PROFILE_TABLE Filtering Categories & Criteria Sampling Specific filtering determined by column combinations IP address or Domain Name LOCATION column (must be only column specified) Plan name, collection identifier, and package name PLANNAME, COLLID, and PKGNAME columns Role or Authorization identifier ROLE or AUTHID columns Collection identifier and/or package name COLLID and/or PKGNAME columns Location name, or location alias LOCATION column Client application name, user ID, or workstation ID CLIENT_APPLNAME, CLIENT_USERID or CLIENT_WRKSTNNAME column All can be wild carded Only * can be specified, enabling an All context for filtering No like wild carding 5 #1: Valid Profiles - DSN_PROFILE_TABLE Categories and columns for monitoring SYSTEM RESOURCES Filtering Category Client IP address or domain name Columns to Specify (Filtering Criteria) Specify only the LOCATION column. The value can be an IP address or domain name. Client product identifier Role or authorization identifier Location name, or location alias Collection identifier or package name Client application name, user ID, or workstation ID Specify only the PRDID column. Specify one or both of the following columns: ROLE or AUTHID Profiles that specify both ROLE and AUTHID take precedence over profiles that specify only one value. Profiles that specify only ROLE take precedence over profiles that specify only AUTHID Specify only the location name or location alias in LOCATION column. This category applies only to profiles that specify MONITOR THREADS and MONITOR IDLE THREADS. Specify one or both of the following columns: COLLID or PKGNAME Profiles that specify both COLLID and PKGNAME take precedence over profiles that specify only one value. Profiles that specify only COLLID take precedence over profiles that specify only PKGNAME Only checks the first SQL COLLID/PKGNAME for the thread. Specify only one of the following columns: CLIENT_APPLNAME, CLIENT_USERID, CLIENT_WRKSTNNAME See the Information Center for evaluation ordering and precedence rules 6 3
#1: Threads and Connections Profiles System Level Monitoring Value of the MAXDBAT subsystem parameter specifies the maximum number of database access threads (DBATs) that are allowed to be concurrently active. 0 to 19999 Default 200 The CONDBAT subsystem parameter sets the maximum number of concurrent inbound DDF connections that are to be allowed. 0 to 150000 Default 10000 CONDBAT must be greater than or equal to MAXDBAT IDTHTOIN subsystem parameter controls the amount of time, in seconds, that an active server thread is to be allowed to remain idle. Timeout value; thread is canceled after the timeout value expires, and its locks and cursors are released 0 to 9999 Default 120 7 #1: Threads and Connections Profiles System Level Monitoring You can monitor threads and connections for remote TCP/IP access to DB2 servers Analyze the use of system resources by particular clients, applications, and users Protects system resources 8 4
#1: Threads and Connections Profiles System Level Monitoring Keywords (Monitoring Functions) MONITOR CONNECTIONS (CONDBAT) Total number of remote connections from TCP/IP requesters including current active connections inactive connections Filtering on LOCATION column only IP Address or Domain Name MONITOR THREADS (MAXDBAT) Total number of concurrent active remote threads that use TCP/IP on the DB2 subsystem Filtering on LOCATION, PRDID, ROLE or AUTHID and COLLID or PKGNAME MONITOR IDLE THREADS (IDTHTOIN) Approximate time (in seconds) that an active server thread is allowed to remain idle A zero value means that matching threads are allowed to remain idle indefinitely 9 #1: Threads and Connections Profiles System Level Monitoring Create a profile by inserting rows in the DSN_PROFILE_TABLE. You must specify one of the valid combinations of filtering criteria for monitoring system activities Specify monitoring function by inserting rows into the DSN_PROFILE_ATTRIBUTES Specify a value for the KEYWORDS column MONITOR THREADS Must be less than or equal to MAXDBAT MONITOR CONNECTIONS Must be less than or equal to CONDBAT MONITOR IDLE THREADS It is not limited to IDTHTOIN 10 5
#1: Monitor Threads and Connections Attributes System Level Monitoring DSN_PROFILE_ATTRIBUTES Continued ATTRIBUTE1 column specifies how DB2 responds when a threshold is met. Action Taken: WARNING - A console message is issued at most every 5 minutes. EXCEPTION - If profile threshold is exceeded, the thread and connection are queued or terminated. Messaging: DIAGLEVEL1 (default) with minimal information (DSNT771I) DIAGLEVEL2 includes PROFILEID and reason code (DSNT772I) For Example WARNING_DIAGLEVEL1 ATTRIBUTE2 column of DSN_PROFILE_ATTRIBUTES table to specify the threshold 11 #1: Threads and Connections System Level Monitoring Type and Level of Detail for Messages Issued for MONITOR CONNECTIONS KEYWORD MONITOR CONNECTIONS - Specifies that DB2 monitors the total number of remote connections including active connections and live inactive connections ATTRIBUTE1 WARNING WARNING_DIAGLEVEL1 WARNING_DIAGLEVEL2 ACTION TAKEN DB2 issues messages when total number of remote connections exceeds the threshold. DB2 issues DSNT771I messages, which provide limited information in the message text about the when the threshold is exceeded. This level is also used when the diagnosis level is not specified. DB2 issues DSNT772I messages, which provide additional details including the specific profile ID and the specific reason code, when the threshold is exceeded EXCEPTION EXCEPTION_DIAGLEVEL1 EXCEPTION DIAGLEVEL2 DB2 issues messages when total number of remote connections exceeds the threshold, and begins to fail remote connection requests with SQLCODE -30041 DB2 issues DSNT771I messages, which provide limited information in the message text about the when the threshold is exceed and begins to fail remote connection requests with SQLCODE -30041. This level is also used when the diagnosis level is not specified. DB2 issues DSNT772I messages, which provide additional details including the specific profile ID and the specific reason code, when the threshold is exceeded and begins to fail remote connection requests with SQLCODE -30041 12 6
#1: Threads and Connections System Level Monitoring Type and Level of Detail for Messages Issued for MONITOR THREADS KEYWORD MONITOR THREADS Specifies that DB2 monitors the total number of concurrent active threads. ATTRIBUTE1 WARNING WARNING_DIAGLEVEL1 WARNING_DIAGLEVEL2 EXCEPTION EXCEPTION_DIAGLEVEL1 EXCEPTION DIAGLEVEL2 ACTION TAKEN DB2 issues messages when total number of active threads exceeds the threshold. DB2 issues DSNT771I messages, which provide limited information in the message text about the when the threshold is exceed. This level is also used when the diagnosis level is not specified. DB2 issues DSNT772I messages, which provide additional details including the specific profile ID and the specific reason code, when the threshold is exceeded. DB2 issues messages when total number of active threads exceeds the threshold, and starts to fail the connection requests with SQLCODE -30041. DB2 issues DSNT771I messages, which provide limited information in the message text about the when the threshold is exceed and begins to queue or fail the connection requests with SQLCODE - 30041. This level is also used when the diagnosis level is not specified. DB2 issues DSNT772I messages, which provide additional details including the specific profile ID and the specific reason code, when the threshold is exceeded and starts to queue or fail the connection requests with SQLCODE -30041 13 #1: Threads and Connections System Level Monitoring Type and Level of Detail for Messages Issued for MONITOR IDLE THREADS KEYWORD MONITOR IDLE THREADS Specifies that DB2 monitors the approximate time (in seconds) that an active server thread is allowed to remain idle. ATTRIBUTE1 WARNING WARNING_DIAGLEVEL1 WARNING_DIAGLEVEL2 ACTION TAKEN DB2 issues messages when the thresholds are exceeded. DB2 issues DSNT771I messages, which provide limited information in the message text about the when the threshold is exceeded. This level is also used when the diagnosis level is not specified. DB2 issues DSNT772I messages, which provide additional details including the specific profile ID and the specific reason code, when the threshold is exceeded. EXCEPTION DB2 issues messages when thresholds are exceeded, and begins to cancel idle threads. EXCEPTION_DIAGLEVEL1 EXCEPTION DIAGLEVEL2 DB2 issues DSNT771I messages, which provides limited information about when the threshold is exceeded and begins to cancel idle threads.. This level is also used when the diagnosis level is not specified. DB2 issues DSNT772I messages, which provide additional details including the specific profile ID, the specific reason code, and begins to cancel idle threads when the threshold is exceeded 14 7
#1: Threads and Connections System Level Monitoring 15 #1: System Level Monitoring Example Column 1: Normal remote thread behavior, governed by MAXDBAT & CONDBAT. Column 2: Profile active for IPAddr/Domain with MONITOR_THREADS set to EXCEPTION. Suspensions start @ MT and continue to CONDBAT. Column 3: Profile active for IPAddr/Domain with MONITOR_THREADS & MONITOR_CONNECTIONS set to EXCEPTION. Threads start suspending @ MT and continue to MC. Column 4:Profile active for non-ipaddr/domain with MONITOR_THREADS set to EXCEPTION. Threads begin suspending @ MT and continue for 2x MT (as long as this is < CONDBAT). Then they are rejected. 16 8
#1: System Level Monitoring Example Profiles Profile 17 would be rejected upon starting because it contains multiple conflicting categories Profile 15 is the only valid profile for MONITOR CONNECTIONS If a thread criteria matched both ROLE_APP and USER1 profile 13 would be used because profiles with both ROLE and AUTHID take precedence If a thread criteria contained ROLE_DBA and USER2 profile 11 would apply 11 12 13 14 15 16 17 What about criteria of ROLE_DBA and USER1? LOCATION TEST.SVL.IBM. COM ROLE ROLE_DBA ROLE_APP ROLE_APP AUTHID USER1 USER1 PRDID SQL09073 SQL09073 COLLID COLL1 PKGNAME 17 #1: System Level Monitoring Example PROFILEID=21 indicates that DB2 monitors system resources that meet the criteria defined by the DSN_PROFILE_TABLE row that contains 21 in the PROFILEID column. When the number of remote connections exceeds 50, DB2 issues a message and continues to service new connection requests. When the active threads exceeds 100, DB2 issues a message and suspends any new thread requests. LOCATION ROLE AUTHID PRDID COLLID PKGNAME 21 DEMOMVS.DEMOPKG.IBM.COM KEYWORDS ATTRIBUTE1 ATTRIBUTE2 ATTRIBUTE3 ATTRIBUTE_ TIMESTAMP 21 MONITOR THREADS EXCEPTION 100 NULL 2008-12-19.. 21 MONITOR IDLE THREADS EXCEPTION 30 NULL 2008-12-17.. 21 MONITOR CONNECTIONS WARNING 50 NULL 2009-1-21.. 18 9
#1: System Level Monitoring Example PROFILEID=21 MONITOR IDLE THREADS indicates that DB2 monitors idle threads that meet the criteria defined by the DSN_PROFILE_TABLE that contains 21 in the PROFILEID column. When a thread remains idle for more than 30 seconds, DB2 issues a message and terminates the idle thread. LOCATION ROLE AUTHID PRDID COLLID PKGNAME 21 DEMOMVS.DEMOPKG.IBM.COM KEYWORDS ATTRIBUTE1 ATTRIBUTE2 ATTRIBUTE3 ATTRIBUTE_ TIMESTAMP 21 MONITOR THREADS EXCEPTION 100 NULL 2008-12-19.. 21 MONITOR IDLE THREADS EXCEPTION 30 NULL 2008-12-17.. 21 MONITOR CONNECTIONS WARNING 50 NULL 2009-1-21.. 19 #1: System Level Monitoring Example PROFILE 35 with associated attribute. Issue a warning when a thread is associated with PRDID SQL09073. DSNT772I csect-name A MONITOR PROFILE condition-type CONDITION OCCURRED number TIME(S) IN =profile-id WITH PROFILE FILTERING SCOPE=filtering-scope WITH REASON=reason-code. Could be used to monitor the use of unsupported software LOCATION ROLE AUTHID PRDID COLLID PKGNAME 35 SQL09073 KEYWORDS ATTRIBUTE1 ATTRIBUTE2 ATTRIBUTE3 ATTRIBUTE_ TIMESTAMP 35 MONITOR THREADS WARNING_DIAG LEVEL2 0 NULL 2008-12-19.. 20 10
#2 Optimization parameters for SQL statements Valid Profile combinations Applicable Filtering Columns (SYSIBM.DSN_PROFILE_TABLE) All of COLLID, PKGNAME, and PLANNAME (Only * ) Applicable Keywords Values (SYSIBM.DSN_PROFILE_ATTRIB UTES) MIN STAR JOIN TABLES, NPAGES THRESHOLD, STAR JOIN 21 #2: Allowable Subsystem Parameters Specify the subsystem parameter that you want to modify in the DSN_PROFILE_ATTRIBUTES table Keywords and Attributes. ZPARM NPGTHRSH KEYWORDS = NPAGES THRESHOLD ATTRIBUTE2 = number of pages ZPARM STARJOIN KEYWORDS = STAR JOIN ATTRIBUTE1 = ENABLE/DISABLE ZPARM SJTABLES KEYWORDS = MIN STAR JOIN TABLES ATTRIBUTE2 = number of tables 22 11
#2: Subsystem Parameters Example KEYWORD NPAGES THRESHOLD STAR JOIN MIN STAR JOIN TABLES ATTRIBUTE(n) Set ATTRIBUTE2 to an integer, 0 or greater, to specify the pages threshold for index access. (NPGTHRSH subsystem parameter) Set ATTRIBUTE1 to DISABLE or ENABLE to specify whether DB2 uses start join processing. (STARJOIN subsystem parameter) Set ATTRIBUTE2 to an integer between 3 and 225 to specify the minimum number of tables for star join processing. (SJTABLES subsystem parameter) 23 #2: Subsystem Parameters Example Insert the following rows into SYSIBM.DSN_PROFILE_TABLE and the SYSIBM.DSN_PROFILE_TABLE table: LOCATION ROLE PLANNAME PRDID COLLID PKGNAME 17 * PRBCOL PRBPACK KEYWORDS ATTRIBUTE1 ATTRIBUTE2 ATTRIBUTE3 ATTRIBUTE_TI MESTAMP 17 STAR JOIN DISABLE 2008-12-19.. Specifies that DB2 is to disable star join processing for all statements that are included in profile 17. 24 12
#3: Production Modeling Attempting to recreate production access paths in development or system test requires more than simply copying production statistics for access path analysis System factors result in different access paths than production? In addition to catalog statistics, optimizer considers: CPU speed # of CPs (for parallelism) BP size RID pool Sort pool 25 #3: Production modeling - Components ZParms SIMULATED_CPU_SPEED SIMULATED_COUNT Also consider NPGTHRSH, PARADEG, and STARJOIN New SYSIBM.DSN_PROFILE_ATTRIBUTES SORT_POOL_SIZE MAX_RIDBLOCKS For bufferpools Same as the BP names listed in the DSNTIP1/2 panels. 26 13
#3 Production Modeling Valid Profile Combinations Applicable Filtering Columns None. Profiles for this purpose have a global scope on the test subsystem. Applicable Keywords Values BPname, MAX_RIDBLOCKS, SORT_POOL_SIZE 27 #3: Obtaining Production Values Obtain existing production values BP information available from DISPLAY BUFFERPOOL command Example jobs to acquire and set production settings in a test environment. http://www.ibm.com/support/docview.wss?uid=swg21470440 Member MDLPROD.COPY contains SQL statements (run on the PROD Subsystem) to capture the CPU speed, number of processors, Rid pool, and sort pool from the IBM_SERVICE_DATA Values converted to integer Member MDLTEST.COPY is an example job that executes SQL to insert and create the profile that incorporates the production values obtained in the MDLROD.COPY member. EXPLAIN will reflect PROFILEID xxxx concatenated into the REASON column of the DSN_STATEMNT_TABLE table. 28 14
#3: Define a Profile INSERT 1 row into profile table using any unique number INSERT INTO SYSIBM.DSN_PROFILE_TABLE (PROFILEID) VALUES(4713); INSERT 1 row into the ATTRIBUTES table for each override INSERT INTO SYSIBM.DSN_PROFILE_ATTRIBUTES (PROFILEID,KEYWORDS,ATTRIBUTE1,ATTRIBUTE2) VALUES (4713, SORT_POOL_SIZE,NULL, 10240000); INSERT INTO SYSIBM.DSN_PROFILE_ATTRIBUTES (PROFILEID,KEYWORDS,ATTRIBUTE1,ATTRIBUTE2) VALUES (4713, BP8K0, NULL, 2500); Update the CPU ZPARMS for the test subsystem SIMULATED_COUNT = 8 SIMULATED_CPU_SPEED = 18 AUTHID PLANNAME AUTHID PRDID COLLID PKGNAME 4713 KEYWORDS ATTRIBUTE1 ATTRIBUTE2 ATTRIBUTE3 ATTRIBUTE_ TIMESTAMP 4713 SORT POOL SIZE 10240000 2008-12-19.. 29 #4: Profiles and IDAA Profiles have the ability to use KEYWORDs to influence whether or not to send a query to an accelerator server ACCEL_TABLE_THRESHOLD (cardinality) Cardinality greater than this value are considered for acceleration -1 disables this check Defaults to 1,000,000 ACCEL_RESULTSIZE_THRESHOLD (number of rows) Expected # of rows below this value are considered for acceleration -1 (disabled) is the default. Values specified are in thousands ACCEL_TOTALCOST_THRESHOLD A query cost greater or equal this value is considered for acceleration -1 for disabled 5000 is the default Use in conjunction with IBM Support 30 15
#5 Setting Special Registers Added to DB2 11 via PM93658 Automatically sets several special registers for remote applications Overrides settings from the drivers Overrides any SET statements before the first SQL statement in the connection Contents are not effected by COMMIT or ROLLBACK Application SETs after the first SQL will override the Profile setting System directed connections use value of requesting site Honors stored procedure INHERIT / DEFAULT SPECIAL REGISTERS 31 #5: Setting Special Registers Applicable Filtering Columns (SYSIBM.DSN_PROFILE_TABLE) LOCATION only Applicable Keywords Values (SYSIBM.DSN_PROFILE_ATTRIBUTES) SPECIAL_REGISTER PRDID only AUTHID, ROLE, or both COLLID, PKGNAME, or both One of CLIENT_APPLNAME, CLIENT_USERID, CLIENT_WORKSTNNAME 32 16
#5 Setting SPECIAL_REGISTER options CURRENT APPLICATION COMPATIBILITY CURRENT DEBUG MODE CURRENT DECFLOAT ROUNDING MODE CURRENT DEGREE CURRENT EXPLAIN MODE CURRENT GET_ACCEL_ARCHIVE CURRENT FUNCTION PATH CURRENT LOCALE LC_CTYPE CURRENT MAINTAINED TABLE TYPES FOR OPTIMIZATION CURRENT MAINTAINED TABLE TYPES CURRENT OPTIMIZATION HINT CURRENT PACKAGE PATH CURRENT PRECISION CURRENT QUERY ACCELERATION CURRENT REFRESH AGE CURRENT ROUTINE VERSION CURRENT RULES CURRENT SCHEMA CURRENT SQLID CURRENT TEMPORAL BUSINESS_TIME CURRENT TEMPORAL SYSTEM_TIME ENCRYPTION PASSWORD PATH SCHEMA SESSION TIME ZONE TIME ZONE 33 #5 Setting Special Registers Examples ATTRIBUTE2/3 are not used The SET statement is1024 bytes max must have a blank around the = must choose valid values special registers Value is used as defined values cannot be expressions ROLE AUTHID PRDID COLLID CLIENT_APPLNAME 11 KILLERAPP KEYWORDS ATTRIBUTE1 11 SPECIAL_REGISTER SET APPLICATION COMPAITBILITY = V11R1 34 17
Defining a Profile A row in the profile table defines one filtering scope Possible to have multiple rows defining more than one scope Filtering category is authorization identifier expressed in the AUTHID column (value: DDS2364) The PROFILE_ENABLED column indicates whether DB2 activates the profile when you issue the START PROFILE command 35 Defining Profile Actions Rows in the SYSIBM.DSN_PROFILE_ATTRIBUTES table control the actions. The values of the PROFILEID columns of each table associate each profile with the corresponding actions for that profile. ( 101 ) 36 18
Starting and stopping profiles You must enable and start profiles before DB2 can use the information in the profile tables Issue a START PROFILE command. DB2 activates the Profiles in the profile tables For every valid row of the SYSIBM.DSN_PROFILE_TABLE table that contains PROFILE_ENABLED='Y (Default) Profiles in rows that contain PROFILE_ENABLED='N' are not started. 37 Validate Profiles are Started Issue the DIS PROFILE command 38 19
Validate The Profile is Accepted SYSIBM.DSN_PROFILE_HISTORY SYSIBM.DSN_PROFILE_ATTRIBUTES_HISTORY Example: 39 Appendix SYSTEM LEVEL Profile examples that DO NOT Work Two PROFILES (DSN_PROFILES_TABLE) with an identical SCOPE will be incompatible. When started the first PROFILE encountered is ACCEPTED Second PROFILE is REJECTED DUPLICATED SCOPE 10 LOCATION DEMOMVS.DEMOPKG.IBM.COM STATUS ACCEPTED - DOMAIN NAME IS RESOLVED INTO IP ADDRESS ::FFFF:9.39.68.147 11 LOCATION DEMOMVS.DEMOPKG.IBM.COM STATUS REJECTED - DUPLICATED SCOPE SPECIFIED 40 20
Appendix SYSTEM LEVEL Profile examples that DO NOT Work One PROFILE (DSN_PROFILES_TABLE) with conflicting scopes will be rejected. LOCATION ROLE AUTHID PRDID COLLID PKGNAME 12 ROLE_DBA SQL09073 COLL1 12 STATUS REJECTED - INVALID SCOPE SPECIFIED. FOR SYSTEM LEVEL MONITOR 41 References DB2 11 for z/os Managing Performance SC19-4060 DB2 11 for z/os Administration Guide SC19-4050 DB2 11 for z/os SQL Reference SC19-4066 Technote: http://www.ibm.com/support/docview.wss?uid=swg2147 0440 42 21