Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Michelle Cavanaugh Information Builders Summit 2010 User Conference June 2010
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2009 CIGNA
Agenda
Introduction & Level Set Basic FOCUS/DB2 Steps DB2 Optimization Steps Traces How to Optimize FOCUS/DB2 Code Examples Q & As
2
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
CIGNA Corporation is An employee benefits company uniquely positioned to help companies succeed and help people enjoy a better quality of life.
Disclaimer: The opinions and conclusions expressed are those of the speaker and not those of CIGNA Corporation.
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
FOCUS calls requested module (TABLE, GRAPH) FOCUS Reads & Parses MFD Parses the request (FOCEXEC) Calls the FOCUS/DB2 Interface
2. FOCUS/DB2 Interface
Reads & Parses the AFD Checks for Optimization System Level Analyzes & Optimizes the request Creates SELECT statements Prepares, allocates & opens cursors Calls DB2 to FETCH the rows of data
3. DB2
FOCUS/DB2 Interface
Analyzes & Optimizes the passed SQL Chooses the access path & retrieval method Retrieves data Creates answer set
DB2
5
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
FOCUS
FOCUS Converts non-standard data into FOCUS formats FOCUS processes are done (IF/WHERE, DEFINEs, etc.) Puts valid rows into the FOCUS Internal Matrix Loops back to get the next row of the DB2 answer set This continues until the end of the answer set SQL code 100+ (End)
FOCUS/DB2 Interface
5. FOCUS
DB2
6
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
FOCUS/DB2 Optimization
Optimization Order 1. Projection & Record Selection Always Done 2. JOINs 3. SORTs 4. Aggregation - When Required
If your code does not pass these steps, your request is not optimized
7
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
FOCUS/DB2 Optimization
1. Projection & Record Selection Translates FOCUS to SQL
Projection Specific columns only SELECT PRINT/SUM/COUNT Fields Objects of JOINs & DEFINEs PRINT * - All columns in Master Never a SELECT * Record Selection SQL WHERE DEFINEs Within a Single Segment YMD or YYMD Date Fields LIKEs - With Same Length or Wildcards (%)* WHERE (T1.<Field> LIKE <Value>) * If different lengths or no wildcards WHERE (T1.<Field> = <value>)
8
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
FOCUS/DB2 Optimization
2. JOIN Optimization
JOIN is Optimized: Single SELECT Statement One DB2 Subsystem (SSID) AFD has KEYS >0 Less than 15 TABLEs in a Single JOIN JOIN Optimized = JOIN Order does not matter JOIN is Not Optimized: FOCUS-Managed JOIN Multiple DB2 Subsystems (SSID) MASTER contains an OCCURS DB2 to Fix files JOIN is NOT Optimized = JOIN Order Critical If JOINs Optimizes SORTs are checked
9
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
FOCUS/DB2 Optimization
3. SORT Optimization
SORT is Optimized: SQL ORDER BY SORT on REAL fields SORT on COMPUTE fields before DEFINE fields With FST. & LST. MFD/AFD KEYs must be correct SORT is Not Optimized if: JOIN was not Optimized Multi-Verb Request ACROSSs, RETYPEs, & COMPUTEs that use Direct Operators Direct Operators that require the Internal Matrix (e.g. TOT.PCT. or RPCT.) If SORT Optimizes Aggregates are checked
10
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
FOCUS/DB2 Optimization
4. Aggregation Optimization Optional
Why? DB2 is much better at aggregation Less data returned to FOCUS Less Data = Faster FOCUS Processing Aggregates that are Translated to SQL: Verbs (SUM, COUNT & WRITE) Direct Operators: MIN. MAX. AVE. Most DEFINE fields - Constant fields using CNT. - Expressions that return with an arithmetic or character string value Aggregates that DO NOT get Translated to SQL: COUNT with MISSING=ON Multi-verb Requests Aggregation can be turned off via the following command: SQL <engine> SET OPTIMIZATION NO AGGR
11
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
Trace Facility
Available Traces
1. STMTRACE Statement Trace 2. SQLAGGR SQL Aggregate Trace 3. SQLDI SQL Details Trace 4. SQLCALL See All Trace
12
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
Trace Facility
1. STMTRACE
All SQL & DDL code All generated SQL code SELECTs & WHEREs All SQL Data Definition Language (DDL) for CREATEs Output can be saved & Run in native SQL Pre- FOCUS 7.2 = FSTRACE4
2. SQLAGGR
JOIN, SORT & Aggregate Optimization Analysis Last optimization level completed Best = AGGREGATION DONE Pre-FOCUS 7.2 = FSTRACE3
13
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
Trace Facility
3. SQLDI
Shows All the details SQL Statements DB2 Return Codes (RC) COMMIT & ROLLBACK Commands SQL Cursor Operations Works with ALL FOCUS Requests Pre-FOCUS 7.2 = FSTRACE
4. SQLCALL
Shows All Commands & Data exchange between Physical & Logical Layers of the Data Adaptor New with FOCUS 7.2
14
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
15
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
Optimization Steps
1. Setup Job for Traces
16
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
Optimization Steps
2. Restrict Data Retrieval
Optimization Steps
4. Activate Selected Traces
18
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
Optimization Steps
You should try for only one SELECT statement There should be WHEREs You should see AGGREGATION DONE
If not return to & try again!
19
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
CIGNA and the Tree of Life logo are registered service marks of CIGNA Intellectual Property, Inc., licensed for use by CIGNA Corporation and its operating subsidiaries. All products and services are provided exclusively by such operating subsidiaries and not by CIGNA Corporation. Such operating subsidiaries include International Rehabilitation Associates, Inc. (Intracorp), CIGNA Behavioral Health, Inc., vielife Limited, Connecticut General Life Insurance Company and HMO subsidiaries of CIGNA Health Corporation. 000000 00/09 2010 CIGNA
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2009 CIGNA
DB2OPT JCL
Allocate all the Required FOCUS files and...
//* ALLOCATE TRACE FILE //FSTRACE DD DSN=TEST.FOCUS.FSTRACE,DISP=SHR //* //SYSIN DD * EXEC DB2OPT <- Opt Set up EXEC <FOCEXEC to be optimized> FIN /* // <- FSTRACE
21
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
22
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
FSTRACE Translation
: TOSS350
(FOC2590) AGGREGATION NOT DONE FOR THE FOLLOWING REASON: (FOC2596) ONE OR MORE EXPRESSION(S) CAN NOT BE TRANSLATED TO SQL
24
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
25
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
Convert DEFINEs to WHEREs Make sure that you are using REAL fields
Modified FOCEXEC
DEFINE FILE HTRARGEL ACCT/A4 = EDIT(SUBACT_NO,'9999$$'); END -* TABLE FILE HTRARGEL PRINT CUST_NUM CLNT_NUM HMO_CD SUBACT_NO MBR_END_DT IF CUST_NUM EQ '9999' IF CLNT_NUM NE '9999' -* CHANGE THE DEFINE TO A WHERE WHERE (HMO_CD EQ '200') AND ((ACCT FROM '0400' TO '0499') OR (ACCT FROM '4800' TO '4999')) IF MBR_END_DT GE '&ENDDT' END
26
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
FSTRACE Output
(FOC2590) AGGREGATION NOT DONE FOR THE FOLLOWING REASON: (FOC2594) AGGREGATION IS NOT APPLICABLE TO THE VERB USED SELECT T1."CUST_NUM",T1."CLNT_NUM",T1."HMO_CD",T1."SUBACT_NO", T1."MBR_END_DT" FROM "WINDSOR2_DB2P"."GHTR"."ARGUS_ELIGIBILITY" T1 WHERE (T1."MBR_END_DT" >= '2008-01-01') AND (T1."HMO_CD" = '200') AND (T1."CLNT_NUM" <> '9999') AND (T1."CUST_NUM" = '9999') AND (((SUBSTR(T1."SUBACT_NO", 1, 4)) BETWEEN '0400' AND '0499') OR ((SUBSTR(T1."SUBACT_NO", 1, 4)) BETWEEN '4800' AND '4999')) FOR FETCH ONLY;
27
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
CIGNA and the Tree of Life logo are registered service marks of CIGNA Intellectual Property, Inc., licensed for use by CIGNA Corporation and its operating subsidiaries. All products and services are provided exclusively by such operating subsidiaries and not by CIGNA Corporation. Such operating subsidiaries include International Rehabilitation Associates, Inc. (Intracorp), CIGNA Behavioral Health, Inc., vielife Limited, Connecticut General Life Insurance Company and HMO subsidiaries of CIGNA Health Corporation. 000000 00/09 2010 CIGNA
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2009 CIGNA
Active JOINs:
? JOIN JOINS CURRENTLY ACTIVE HOST FIELD FILE TAG ---------NDC_NUM HTRACLM CUST_NUM HTRACLM CLM_NUM HTRACLM
CROSSREFERENCE FIELD FILE TAG ---------NDC_NUM HTRNDC CUST_NUM HTRARGEL CLM_NUM HTRCLSTF
29
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
HOST
JOIN1
JOIN2
JOIN3
30
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
31
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
32
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
34
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
35
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
OFF = Always tries to Optimizes - DEFAULT ON = Outer JOIN Missing cross-referenced rows are processed R 7.0.9
SET <SQL engine> SET SQLJOIN OUTER ON/OFF
39
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
40
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2010 CIGNA
CIGNA and the Tree of Life logo are registered service marks of CIGNA Intellectual Property, Inc., licensed for use by CIGNA Corporation and its operating subsidiaries. All products and services are provided exclusively by such operating subsidiaries and not by CIGNA Corporation. Such operating subsidiaries include International Rehabilitation Associates, Inc. (Intracorp), CIGNA Behavioral Health, Inc., vielife Limited, Connecticut General Life Insurance Company and HMO subsidiaries of CIGNA Health Corporation. 000000 00/09 2010 CIGNA
Confidential, unpublished property of CIGNA. Do not duplicate or distribute. Use and distribution limited solely to authorized personnel. 2009 CIGNA