Adding an expression to a What-If Index
At the Explain Object Specification panel, select Ad Hoc SQL and press Enter.An editing panel (see Explain Edit panel) is displayed.
EDIT EXPLAIN Columns 00001 00080
Command ===> Scroll ===> CSR
****** ********************************* Top of Data**********************
==MSG> -Warning- The UNDO command is not available until you change
==MSG> your edit profile using the command RECOVERY ON.
000001 SELECT EMPNO
000002 FROM PSS.EMP
000003 WHERE UPPER(LASTNAME, 'EN_US') = 'JOE'
000004 AND UPPER(FIRSTNME, 'EN_US') = 'JOHN'Enter the SQL statements that you want to use and press F3.The Explain or Execute Parameters panel is displayed.
PSSPA117 ----------------- Explain or Execute Parameters ---------------------
Command ===>
Specify the options below and press ENTER to continue.
Option . . . . 1 1. Explain
2. Execute
3. Edit
Qualifier Name SYSIBMAt the Explain or Execute Parameters panel, select Explain and press Enter.The Explain Results panel (see Explain Results panel showing an ad hoc query) is displayed.
FILE COMMANDS OPTIONS HELP
-------------------------------------------------------------------------------
DEDR Explain Results for SQLTEXT
Command ===> Scroll ===> CSR
More: >
Actions: S H R RS RW RI XD XS XP W P T C D U IM SA
LBL STMTNO COST*RATE SQL-STATEMENT
C XD01 0 126.728729 SELECT EMPNO FROM PSS.EMP WHERE UPPER(LASTNAME, '
COST*RATE QB PL MIX QTYPE METH ACC MTCH IX TBNAME IXNAME
XD01 126.72872 1 1 0 SELECT 0 I 2 N EMP UPPER_ETo create a clone of the object upon which you want to perform the What-If analysis, type C in the space beside the object, and press Enter.The Explain Results panel (see Explain Results panel showing the clone) shows the clone.
FILE COMMANDS OPTIONS HELP
-------------------------------------------------------------------------------
PSSPW200 Explain Results for SQLTEXT
Command ===> Scroll ===> CSR
More: >
Actions: S H R RS RW RI XD XS XP W P T C D U IM SA
CLONE Objects in database PSS47404
STMTNO SQL-STATEMENT
0 SELECT EMPNO FROM PSS.EMP WHERE UPPER(LASTNAME, 'EN_US') = 'JOE' AND U
TBNAME CARD NPAGES COMP NACTIVE PARENT CHILD BPOOL DATAB
W EMP -1 -1 -1 -1 0 0 BP0 PSSQA
IXNAME 1STKEY FULLKEY NLEAF NLEVELS CLUSTERRATIO CLUS
EMPFULLNAM -1 -1 -1 -1 0.0000000000 N
TESTIXEMPN -1 -1 -1 -1 0.0000000000 N
TOTAL_COMP -1 -1 -1 -1 0.0000000000 N- To specify a What-If Index, type W in the space beside the table and press Enter.The Specify Index Attributes panel is displayed.
- Specify attributes for a new index to be added to the table, select Specify key columns, and press Enter.The Select Key Columns panel is displayed. If the table already had some indexed expressions, those expressions are displayed on the panel.
To add an expression to the key columns list, perform the following steps:
- In the SEQ field next to the column that you want to include in the expression, type E and press Enter.
In the editing panel (see Explain Edit panel showing an expression), enter the expression upon which you want to create an index.
ISREDDE2 EXPLAIN Columns 00001 00080
Command ===> Scroll ===> CSR
************************ Top of Data ******************************
000001 SALARY + BONUS
****** **************************Bottom of Data *******************- Press F3 to return to the Select Key Columns panel.
The Select Key Columns panel (see Select Key Columns showing an expression) displays the expression that you created.
PSSPW300 Select Key Columns
Command ===> Scroll ===> CSR
More: >
Actions: S H E
STMTNO SQL-STATEMENT
0 SELECT EMPNO FROM PSS.EMP WHERE UPPER(LASTNAME, 'EN_US') = 'JO
For each column of the key, enter the key column sequence number
and the order (Ascending, Descending, Random, or blank).
SEQ ORDER EXPRESSION
1 A SALARY + BONUS
SEQ ORDER COLNO COLUMN NAME CARD TYPE LEN HI2KEY L
2 A 1 EMPNO -1 CHAR 6
A 2 FIRSTNME -1 VARCHAR 12
A 3 MIDINIT -1 CHAR 1
3 A 4 LASTNAME -1 VARCHAR 15
A 5 WORKDEPT -1 CHAR 3
A 6 PHONENO -1 CHAR 4
A 7 HIREDATE -1 DATE 4
A 8 JOB -1 CHAR 8
A 9 EDLEVEL -1 SMALLINT 2
A 10 SEX -1 CHAR 1
A 11 BIRTHDATE -1 DATE 4
A 12 SALARY -1 DECIMAL 9
A 13 BONUS -1 DECIMAL 9
A 14 COMM -1 DECIMAL 9To select the key columns for the index, specify sequence numbers (SEQ) and order (ascending (A) or descending (D)).
- Press F3 to return to the Explain Results panel.The new index is displayed in the list. At this point, the index has not yet been created; it is created when you perform the Explain.
- To perform a dynamic Explain, type XD in the space beside the clone and press Enter.The results of the Explain are displayed. The WI01 label represents the Explain on the statement for the cloned objects. The asterisk and highlighting make it easier to visually identify the differences between the Explains.
To show the cloned objects, type S in the space beside the cloned object and press Enter. Then, type S next to the index and press Enter.The Explain Results panel (see Explain Results panel showing an index on expression) shows the detailed information.
FILE COMMANDS OPTIONS HELP
-------------------------------------------------------------------------------
PSSPW200 Explain Results for SQLTEXT
Command ===> Scroll ===> CSR
More: +
Actions: S H R RS RW RI XD XS XP W P T C D U IM SA
CLONE Objects in database PSS44781
STMTNO SQL-STATEMENT
0 SELECT EMPNO FROM PSS.EMP WHERE UPPER(LASTNAME, 'EN_US') = 'JOE' AND UPPER(FI
TBNAME CARD NPAGES COMP NACTIVE PARENT CHILD BPOOL DATABASE LOC
EMP -1 -1 -1 -1 0 0 BP0 PSSQADB T
IXNAME 1STKEY FULLKEY NLEAF NLEVELS CLUSTERRATIO CLUSTERING CL
EMPFULLNAM -1 -1 -1 -1 0.0000000000 N N
TESTIXEMPN -1 -1 -1 -1 0.0000000000 N N
TOTAL_COMP -1 -1 -1 -1 0.0000000000 N N
UPPER_EMPN -1 -1 -1 -1 0.0000000000 N N
XEMP2 -1 -1 -1 -1 0.0000000000 N N
myindex2 0 0 20 2 0.8000000000 N
KEY COLUMN COLNO ORDERING
SALARY + BONUS 0 A
LASTNAME 4 A
LBL STMTNO COST*RATE SQL-STATEMENT
XD01 0 126.728729 SELECT EMPNO FROM PSS.EMP WHERE UPPER(LASTNAME, 'EN_US')
COST*RATE QB PL MIX QTYPE METH ACC MTCH IX TBNAME IXNAME
XD01 126.72872 1 1 0 SELECT 0 I 2 N EMP UPPER_EMPNAME