Presentation is loading. Please wait.

Presentation is loading. Please wait.

Agenda Overview of pureXML in DB2 9 for z/OS

Similar presentations


Presentation on theme: "Agenda Overview of pureXML in DB2 9 for z/OS"— Presentation transcript:

0 Ten Essential DBA Tasks for DB2 9 for z/OS pureXML
Guogen (Gene) Zhang, STSM, IBM SVL, Steve Chen, STSM, IBM SVL, Session Number 1810

1 Agenda Overview of pureXML in DB2 9 for z/OS
Ten DBA tasks for pureXML in DB2 9 for z/OS Q & A Buffer Pool: change default, and ALTER individual TS for TS and index BPOOL.

2 What You Can Do with pureXML
- Managing XML data the same way as relational data Create tables with XML columns or alter table add XML columns Insert XML data, optionally validated against schemas Create indexes on XML data Efficiently search XML data Extract XML data Decompose XML data into relational data or create relational view Construct XML documents from relational and XML data Handle XML data with the utilities and tools XML

3 XML and the Web before DB2 pureXML
Client Application Server Relational Database Mapping Mapping XML Objects Relational schema XML to object mapping and object to relational mapping Very costly Complex Inflexible

4 DB2 pureXML and the Web End-to-End XML SOA-Gateway
relational Client DB2 pureXML End-to-End XML No expensive object mapping Pass Thru XML from/to database SOA-Gateway Device/application to handle network protocols, security, reliability, performance Easy to manage Simple pre- and post-processing of XML – e.g. via XSLT

5 XML Storage on Mature Infrastructure
DocID index XML index (user) B+tree NodeID index B+tree B+tree Base Table Regular Table space Internal XML Table DocID XMLCol DOCID MIN_NODEID XMLData (DB2_GENERATED_DOCID_FOR_XML) 1 1 02 2 2 02 3 2 0208 3 02 A table with an XML column has a DocID column, used to link from the base table to the XML table. A DocID index is used for getting to base table rows from XML indexes. Each XMLData column is a VARBINARY, containing a subtree or a sequence of subtrees, with context path. Rows in XML table are freely movable, linked with a NodeID index.

6 XML Objects for Non-partitioned Base Table
Default: Maxpartitions – 256, SEGSIZE 4, DSSIZE 4G XML Index NODEID INDEX Cols: DOCID MIN_NODEID XMLDATA DOCID INDEX Table for XMLCol1 PBG TS for XMLCol1 Cols: DOCID XMLCol1 XMLCol2 XML Index NODEID INDEX BASE Table Cols: DOCID MIN_NODEID XMLDATA Non-Partioned Base TS (simple, segmented, PBG) Table for XMLCol1 PBG TS for XMLCol2

7 XML Objects for Partitioned Base Table
DSSIZE depends on base table page size (critical: max num parts) NodeID INDEX (NPI) XML Index (NPI) Part1 Part2 DOCID MIN_NODEID XMLDATA DOCID MIN_NODEID XMLDATA DOCID INDEX (NPI) Partitioned TS for XMLCol1 Cols: DOCID XMLCOL1 XMLCOL2 Cols: DOCID XMLCOL1 XMLCOL2 NodeID INDEX (NPI) XML Index (NPI) BASE Table Part1 BASE Table Part2 Part1 Partitioned Base TS 2 Parts, Table has 2 XML Coumns Part2 DOCID MIN_NODEID XMLDATA DOCID MIN_NODEID XMLDATA Partitioned TS for XMLCol2

8 A few Things that are New related to XML
Implicitly created objects – DBA cannot create explicitly XML indexes: XPath and keys XML Schema registration XMLDATA contains StringIDs in a catalog table SYSIBM.SYSXMLSTRINGS (dictionary) UNLOAD FROMCOPY restricted, DSN1COPY A new XML lock type, ID '35'x in traces IFCID 20, 21, 107, 150, 172, and 196. XML keyword in some utilities 4 implies that UNLOAD FROMCOPY does not work and copy from DSN1COPY cannot be moved to another system.

9 Overview of utilities for XML
No new special utilities for XML. DB2 utilities support the XML data type and the related database objects The XML data type in LOAD and UNLOAD, with file reference support Support for the XML table spaces and tables used to store XML column values Support for auxiliary relationships used to connect base tables to XML tables Support for the base table space DocID index Support for the XML table space NodeID index and XML indexes No partition level checking for XML PBG UTS(APAR pk49033) DSN1COPY copied data set containing XML objects cannot be moved to another system due to StringIDs (dictionary specific to each system).

10 New Keywords or Functionality
CHECK DATA adds the processing of XML objects to AUXERROR and AUXONLY LISTDEF implements a new XML keyword for the building of lists with and without XML objects LOAD implements a new field type, XML, in the field-spec. Additional keywords for XML fields to specify how white space is to be handled (PRESERVE WHITESPACE) UNLOAD implements a new field type, XML, in the field-spec

11 Ten Essential DBA Tasks for pureXML
XML-related configurations XML document, table, and index design Registering XML schemas Finding dependent objects for XML LOAD/UNLOAD

12 Ten Essential DBA Tasks for pureXML (Cont’d)
REORG and RUNSTATS Backup and recovery Diagnosing data problems - CHECK DATA and REPAIR Checking query plans Performance monitoring

13 1. XML-related Configurations
Basic XML parsing requires z/OS XMLSS: z/OS 1.8 or z/OS 1.7 with APAR OA16303 XML schemas require IBM 31-bit SDK for z/OS, Java 2 Technology Edition, V5 (5655-N98), SDK V1.5. And Java stored procedure setup. Zparms for virtual storage: XMLVALA and XMLVALS Default: 200MB and 10GB. Also LOBVALA and LOBVALS impact bind-in and bind-out of XML Buffer pool for XML tables (default BP16K0), authorization for users who create or alter tables with XML columns. DEFAULT BUFFER POOL FOR USER XML DATA ===> BP16K0 BP16K0 - BP16K9

14 Command Line Processor (CLP) – Setup in Windows
Official support on Unix System Service (USS), but works on Windows Set up JCC driver on Windows Set up CLP: Put clp.jar in a directory, say …\path Set up file clp.properties (optional): TerminationChar=# mydb2=hostname.svl.ibm.com:446/LOC,USER,PASSWD Set environment variables: CLASSPATH = …; …\path\clp.jar CLPPROPERTIESFILE=…\path\clp.properties (Bind metadata routines – execute job V91TIJMS) For convenience, on Windows: set db2=java com.ibm.db2.clp.db2 Then use %db2% to invoke CLP

15 XSR (XML Schema Repository) Setup
A set of DB2 user tables, stored procedures, and a user-defined function: XSR tables: SYSIBM.XSROBJECTS and other XSR* tables Schema registration: XSR_REGISTER, XSR_ADDSCHEMADOC, XSR_COMPLETE, XSR_REMOVE Schema validation: DSN_XMLVALIDATE (UDF) Decomposition: XDBDECOMPXML Setup required: Bind package SYSXSR (install/migration jobs DSNTIJSG and DSNTIJNX, or manual run for PTF) Java 2 SDK V1.5, JCC for DB2 9 for z/OS, and bind the JCC packages to SYSXSR collection ID WLM for stored procedures and functions (default WLMENV3) WLM for Java stored procedure (needed for XSR_COMPLETE) //V91AWLM3 PROC DB2SSN=V91A,NUMTCB=18,APPLENV=WLMENV3 //TCBNUM18 EXEC PGM=DSNX9WLM,TIME=NOLIMIT, // PARM='&DB2SSN,&NUMTCB,&APPLENV', // REGION=0M //STEPLIB DD DSN=DB2A.SDSNLOD2,DISP=SHR // DD DSN=DB2A.SDSNLOAD,DISP=SHR // DD DSN=CEEA.SCEERUN,DISP=SHR //SYSTSPRT DD SYSOUT=* //CEEDUMP DD SYSOUT=* //SYSPRINT DD SYSOUT=* //V91AWLJA PROC DB2SSN=V91A,NUMTCB=2,APPLENV=WLMJAVA //TCBNUM1 EXEC PGM=DSNX9WLM,TIME=NOLIMIT, //STEPLIB DD DSN=DB2A.SDSNLOD2,DISP=SHR // DD DSN=DB2A.SDSNLOAD,DISP=SHR // DD DSN=CEEA.SCEERUN,DISP=SHR //JAVAENV DD DSN=WLMJAVA.JSPENV,DISP=SHR //JSPDEBUG DD SYSOUT=A //CEEDUMP DD SYSOUT=A //SYSPRINT DD SYSOUT=A

16 2. XML document, table and index design
Documents should match most frequent access unit. Most efficient way of table design is hybrid. Put the keys in relational columns. Use XML for its flexibility to avoid relational normalization Use XMLTable view to experiment the design alternatives. Same table view, different storage for performance testing Create indexes on searched elements/attributes of XML. Use larger segment size for XML table spaces (inherited from base for the time being) for heavy insertion. To alleviate the contention at the end of XML TS.

17 Table Space Size Consideration
Basic XML storage is about 0.3 (strip ws w/ compression) to 1.5 (preserve ws w/o compression) of original doc size An XML table space always use 16KB pages. For non partitioned base table spaces, PBG table space is used for XML. Range-partitioned base table spaces: XML partitioning follows base table partitioning. The number of rows to fit into a relational partition is limited by the number of documents to fit into an XML partition. For example, 4K doc size, 32GB partition can roughly store 8M documents (or 6M to be safe).

18 XML Indexing Each index adds 15-20% CPU time to the basic INSERT cost. Create indexes that are only needed. Exception: large number of XML indexes for the benefit of flexibility Specify full path for index XML patterns, avoid wild card, or descendant axis Rebuild index is recommended over create index for existing data Code XPath conditions that will match index patterns in queries.

19 Query Predicate Must Match Index Data Type
<customerinfo cid=“1004”> <name>Matt Foreman</name> <phone> </phone> </customerinfo> Index definition Predicate …using xmlpattern as SQL VARCHAR(10); …using xmlpattern as SQL DECFLOAT; XMLEXISTS( = “1004”]’ …) XMLEXISTS(‘ = 1004]’ …) It’s a string The quotes in the predicate imply numeric comparison vs. string comparison. String comparison can only be done with a varchar index, not with a numeric index. Numeric comparison can only be done with a numeric index, not with a varchar index. Why? 2 < 13 is true for number, but “2” < “13” is false for strings. Strings and numbers have different collation (sort order) even if they “look” the same. It’s a number Index used Index not used What about = “1004”]/name’ …) ? And = 1004]/name’ …) ?

20 XML Index should “contain” query predicates
create table customer(info XML); <customerinfo cid=“1004”> <name>Matt Foreman</name> <phone> </phone> </customerinfo> Assume we expect predicates on “phone”. There are several ways to index this, including: Option 1: create index idx1 on customer(info) generate key using xmlpattern '/customerinfo/phone' as SQL varchar(40); Option 2: create index idx2 on customer(info) generate key using xmlpattern '//phone' as SQL varchar(40); Option 3: create index idx1 on customer(info) generate key using xmlpattern '/customerinfo/*' as SQL varchar(40); Using a full path is often the right choice.

21 Query predicate examples
<customerinfo cid=“1004”> <name>Matt Foreman</name> <phone> </phone> </customerinfo> Consider these index/predicate pairs: Index definition Predicate …using xmlpattern '/customerinfo/phone‘ as sql varchar(35); …using xmlpattern '//phone‘ …using xmlpattern '/customerinfo/*‘ EXISTS(‘$i//phone [. = “ ”]’ …) XMLEXISTS( ‘$i/customerinfo [phone = “ ” ]’ …) EXISTS(‘$i/customerinfo [* = “ ”]’ … ) This slide is all about “containment”. The green check mark indicates that the index in the column contains at least all the nodes (elements in this case) which are requested by the predicate in the row. This means that the index can be used without the risk of returning an incomplete result. The red cross indicates that the query predicate (row) applies to nodes which are not contained in the index (column). This means the index cannot be used because it might return an incomplete query result.

22 Use Fully Specified Paths in XPath
If customerinfo were a record in a programming language, what would you do to address “city”? customerinfo.addr.city This is what XPath should be: /customerinfo/addr/city, not //city Wildcard * and // should be used with a real reason. * for generic search need // for recursive documents or nodes appearing at different paths or levels. <customerinfo Cid="1004"> <name>Matt Foreman</name> <addr country="Canada"> <street>1596 Baseline</street> <city>Toronto</city> <state>Ontario</state> <pcode>M3Z-5H9</pcode> </addr> <phone type="work"> </phone> <phone type="home"> </phone> </customerinfo>

23 3. Registering XML Schemas
Use CLP or Data Studio for non programming interface Register schema in CLP REGISTER XMLSCHEMA FROM file://C:/xmlschema/order.xsd AS SYSXSR.ORDERSCHEMA ADD FROM file://C:/xmlschema/lineitem.xsd ADD FROM file://C:/xmlschema/parts.xsd COMPLETE [ENABLE DECOMPOSITION]; Remove schema REMOVE XMLSCHEMA SYSXSR.ORDERSCHEMA; SchemaLocation SQL Identifier SchemaLocation

24 Enforcing Schema Validation for INSERT
Create SQL PL stored procedure CREATE PROCEDURE INSERTMYTABLEVALID (IN col1 INT, IN xmlcol BLOB(1M)) LANGUAGE SQL BEGIN INSERT INTO MYTABLE VALUES( col1, XMLPARSE(DOCUMENT DSN_XMLVALIDATE(xmlcol, ‘SYSXSR.ORDERSCHEMA’)) ); END Applications call CALL INSERTMYTABLEVALID(1, :blob);

25 4. Finding Dependent Objects for XML
LISTDEF: List of related objects for utilities REPORT TABLESPACESET Query catalog tables: SYSIBM.SYSXMLRELS: table.XMLcol =>internal XMLTABLE

26 LISTDEF – define a list of related objects
Example: LISTDEF listname INCLUDE TABLESPACES TABLESPACE tsname [RI] [ALL | BASE | LOB | XML] Valid specifications: BASE (non-LOB and non-XML objects) LOB (LOB objects) XML (XML objects) ALL (BASE, LOB, and XML objects) TABLESPACES (related table spaces) INDEXSPACES (related index spaces) RI (related by referential constraints, including informational referential constraints) Initial object can be: DB, TS, IS, Table, Index

27 REPORT TABLESPACESET - Output
Contains both a LOB column and an XML column: POTABLE(I INT, CHARPO CLOB, PO XML). (New XML text is shown in red) TABLESPACE SET REPORT: TABLESPACE : DBMYPO.TSMYPO TABLE : ADMF001.POTABLE INDEXSPACE : DBMYPO.IRDOCIDP INDEX : ADMF001.I_DOCIDPOTABLE LOB TABLESPACE SET REPORT: TABLESPACE : DBMYPO.TSMYPO BASE TABLE : ADMF001.POTABLE COLUMN : CHARPO LOB TABLESPACE : DBMYPO.TSLOBPO AUX TABLE : ADMF001.TBLOBPO AUX INDEXSPACE : DBMYPO.IXLOBPO AUX INDEX : ADMF001.IXLOBPO XML TABLESPACE SET REPORT: COLUMN : PO XML TABLESPACE : DBMYPO.XPOT0000 XML TABLE : ADMF001.XPOTABLE XML NODEID INDEXSPACE: DBMYPO.IRNODEID XML NODEID INDEX : ADMF001.I_NODEIDXPOTABLE XML INDEXSPACE : DBMYPO.XMLIDX XML INDEX : ADMF001.XMLIDX TABLESPACE : DBMYPO.TSMYPO BASE TABLE : ADMF001.POTABLE COLUMN : PO XML TABLESPACE : DBMYPO.XPOT0000 XML TABLE : ADMF001.XPOTABLE XML NODEID INDEXSPACE: DBMYPO.IRNODEID XML NODEID INDEX : ADMF001.I_NODEIDXPOTABLE XML INDEXSPACE : DBMYPO.XMLIDX XML INDEX : ADMF001.XMLIDX TABLESPACE SET REPORT: TABLESPACE : DBMYPO.TSMYPO TABLE : ADMF001.POTABLE INDEXSPACE : DBMYPO.IRDOCIDP INDEX : ADMF001.I_DOCIDPOTABLE LOB TABLESPACE SET REPORT: TABLESPACE : DBMYPO.TSMYPO BASE TABLE : ADMF001.POTABLE COLUMN : CHARPO LOB TABLESPACE : DBMYPO.TSLOBPO AUX TABLE : ADMF001.TBLOBPO AUX INDEXSPACE : DBMYPO.IXLOBPO AUX INDEX : ADMF001.IXLOBPO XML TABLESPACE SET REPORT: COLUMN : PO XML TABLESPACE : DBMYPO.XPOT0000 XML TABLE : ADMF001.XPOTABLE XML NODEID INDEXSPACE: DBMYPO.IRNODEID XML NODEID INDEX : ADMF001.I_NODEIDXPOTABLE XML INDEXSPACE : DBMYPO.XMLIDX XML INDEX : ADMF001.XMLIDX

28 Querying Catalog Tables
Find internal XML table name SELECT XMLTBOWNER, XMLTBNAME FROM SYSIBM.SYSXMLRELS WHERE TBOWNER = ? AND TBNAME = ? AND COLNAME = ? Find tablespace and stogroup SELECT TP.DBNAME, TP.TSNAME, TP.STORNAME, TP.PQTY, TP.SQTY FROM SYSIBM.SYSTABLEPART TP, SYSIBM.SYSTABLES TB WHERE TP.TSNAME = TB.TSNAME AND TP.DBNAME = TB.DBNAME AND TB.NAME = ? AND TB.CREATOR = ?

29 5. LOAD XML Data LOAD uses internal INSERT for XML data – honors LOG(NO). To load XML directly from input records, specify XML as the field type. LOAD DATA INDDN(INFILE) LOG NO RESUME(NO) FORMAT DELIMITED INTO TABLE PURCHASEORDERS LOAD DATA INDDN(INFILE) LOG NO RESUME(NO) … XMLPO POSITION(20) XML PRESERVE WHITESPACE INTO TABLE PURCHASEORDERS To load XML from files, specify CHAR or VARCHAR along with either BLOBF, CLOBF or DBCLOBF. Schema validation not supported for LOAD. XML compression takes effect after first REORG, not on initial LOAD. Same for FREEPAGE, PCTFREE.

30 UNLOAD XML Data To unload XML data directly to output records, specify XML as the field type. non-delimited format: a 2-byte length will precede the value of the XML. For delimited output, no length field is present. Limit to 32K in length To unload XML data to separate files: Specify CHAR(n)/VARCHAR(n) BLOBF, CLOBF or DBCLOBF for file names Use the template control statement to create the XML output file and filename UNLOAD FROMCOPY is restricted

31 File References – UNLOAD to PDS (1/2)
//UNLOADFP JOB ... // MSGCLASS=A,MSGLEVEL=(1,1),USER=..., // PASSWORD=...,REGION=4096K /*ROUTE PRINT ... //STEP1 EXEC DSNUPROC,UID='SAMPLE.UNLDF', // UTPROC='', // SYSTEM=‘...' //UTPRINT DD SYSOUT=* //SYSREC DD DSN=SAMPLE.UFILEREF.SYSREC,DISP=(MOD,CATLG,CATLG), // UNIT=SYSDA,SPACE=(4000,(20,20),,,ROUND) //SYSPUNCH DD DSN=SAMPLE.UFILEREF.SYSPUNCH, // DISP=(MOD,CATLG,CATLG), //SYSUT1 DD DSN=SAMPLE.UFILEREF.STEP1.SYSUT1, // DISP=(MOD,DELETE,CATLG), //SORTOUT DD DSN=SAMPLE.UFILEREF.STEP1.SORTOUT, //SYSIN DD * (continued on next chart) //UNLOADFP JOB 'USER=$$USER','$$USER',CLASS=A, // MSGCLASS=A,MSGLEVEL=(1,1),USER=ADMF001, // PASSWORD=ADMF001,REGION=4096K /*ROUTE PRINT STLVM14.JOETANG //******************************************************************** //* COMMENT: //* //STEP1 EXEC DSNUPROC,UID='SAMPLE.UNLDF', // UTPROC='', // SYSTEM='SSTR' //UTPRINT DD SYSOUT=* //SYSREC DD DSN=SAMPLE.UFILEREF.SYSREC,DISP=(MOD,CATLG,CATLG), // UNIT=SYSDA,SPACE=(4000,(20,20),,,ROUND) //SYSPUNCH DD DSN=SAMPLE.UFILEREF.SYSPUNCH, // DISP=(MOD,CATLG,CATLG), //SYSUT1 DD DSN=SAMPLE.UFILEREF.STEP1.SYSUT1, // DISP=(MOD,DELETE,CATLG), //SORTOUT DD DSN=SAMPLE.UFILEREF.STEP1.SORTOUT, //SYSIN DD * TEMPLATE TCLOBF UNIT(SYSDA) DISP(MOD,CATLG,DELETE) DSN(SAMPLE.&TS..T&TI..&SN..UFILEREF) DSNTYPE(PDS) DIR(15) VOLUMES(SCR03) UNLOAD TABLESPACE SAMPLEDB.SAMPLETS PUNCHDDN SYSPUNCH UNLDDN SYSREC FROM TABLE ADMF001.SAMPLETB ( MYCOL POSITION(*) DECIMAL(5,2) ,MYXML POSITION(*) VARCHAR CLOBF TCLOBF ) /*

32 File References – UNLOAD to PDS (2/2)
TEMPLATE TCLOBF UNIT(SYSDA) DISP(MOD,CATLG,DELETE) DSN(SAMPLE.&TS..T&TI..&SN..UFILEREF) DSNTYPE(PDS) DIR(15) VOLUMES(SCR03) UNLOAD TABLESPACE SAMPLEDB.SAMPLETS PUNCHDDN SYSPUNCH UNLDDN SYSREC FROM TABLE ADMF001.SAMPLETB ( MYCOL POSITION(*) DECIMAL(5,2) ,MYXML POSITION(*) VARCHAR CLOBF TCLOBF ) &TS. Table space name &TI. Time &SN. Space name DIR number of 256-byte records for directory SAMPLE.UFILEREF.SYSREC SAMPLE.XSAM0000.T XSAM0000.UFILEREF(BI0MSW37) SAMPLE.XSAM0000.T XSAM0000.UFILEREF(BI0MSW5K) SAMPLE.XSAM0000.T XSAM0000.UFILEREF(BI0MSW55) SAMPLE.XSAM0000.T XSAM0000.UFILEREF(BI0MSW6S) SAMPLE.XSAM0000.T XSAM0000.UFILEREF(BI0MSW7E) //UNLOADFP JOB 'USER=$$USER','$$USER',CLASS=A, // MSGCLASS=A,MSGLEVEL=(1,1),USER=ADMF001, // PASSWORD=ADMF001,REGION=4096K /*ROUTE PRINT STLVM14.JOETANG //******************************************************************** //* COMMENT: //* //STEP1 EXEC DSNUPROC,UID='SAMPLE.UNLDF', // UTPROC='', // SYSTEM='SSTR' //UTPRINT DD SYSOUT=* //SYSREC DD DSN=SAMPLE.UFILEREF.SYSREC,DISP=(MOD,CATLG,CATLG), // UNIT=SYSDA,SPACE=(4000,(20,20),,,ROUND) //SYSPUNCH DD DSN=SAMPLE.UFILEREF.SYSPUNCH, // DISP=(MOD,CATLG,CATLG), //SYSUT1 DD DSN=SAMPLE.UFILEREF.STEP1.SYSUT1, // DISP=(MOD,DELETE,CATLG), //SORTOUT DD DSN=SAMPLE.UFILEREF.STEP1.SORTOUT, //SYSIN DD * TEMPLATE TCLOBF UNIT(SYSDA) DISP(MOD,CATLG,DELETE) DSN(SAMPLE.&TS..T&TI..&SN..UFILEREF) DSNTYPE(PDS) DIR(15) VOLUMES(SCR03) UNLOAD TABLESPACE SAMPLEDB.SAMPLETS PUNCHDDN SYSPUNCH UNLDDN SYSREC FROM TABLE ADMF001.SAMPLETB ( MYCOL POSITION(*) DECIMAL(5,2) ,MYXML POSITION(*) VARCHAR CLOBF TCLOBF ) /* SAMPLE.XSAM0000.T XSAM0000.UFILEREF: BI0MSW37 BI0MSW5K BI0MSW55 BI0MSW6S BI0MSW7E

33 File References – LOAD from PDS (1/2)
//LOADXML5 JOB ... // MSGCLASS=A,MSGLEVEL=(1,1),USER=...,REGION=4096K, // PASSWORD=... /*ROUTE PRINT ... //STEP1 EXEC DSNUPROC,UID='SAMPLE.LOADXML3',TIME=1440, // UTPROC='', // SYSTEM=‘...',DB2LEV=DB2A //SYSREC DD DSN=SAMPLE.UFILEREF.SYSREC,DISP=(MOD,CATLG,CATLG), // UNIT=SYSDA,SPACE=(4000,(20,20),,,ROUND) //SYSERR DD DSN=SAMPLE.LOADXML3.STEP1.SYSERR, // DISP=(MOD,DELETE,CATLG),UNIT=SYSDA, // SPACE=(4000,(20,20),,,ROUND) //SYSDISC DD DSN=SAMPLE.LOADXML3.STEP1.SYSDISC, //SYSMAP DD DSN=SAMPLE.LOADXML3.STEP1.SYSMAP, //SYSUT1 DD DSN=SAMPLE.LOADXML3.STEP1.SYSUT1, //UTPRINT DD SYSOUT=* //SORTOUT DD DSN=SAMPLE.LOADXML3.STEP1.SORTOUT, //SYSIN DD * (continued on the next chart) //LOADXML5 JOB 'USER=$$USER','<USERNAME:JOBNAME>',CLASS=A, // MSGCLASS=A,MSGLEVEL=(1,1),USER=ADMF001,REGION=4096K, // PASSWORD=ADMF001 /*ROUTE PRINT STLVM14.JOETANG //******************************************************************** //* COMMENT: //* //STEP1 EXEC DSNUPROC,UID='SAMPLE.LOADXML3',TIME=1440, // UTPROC='', // SYSTEM='SSTR',DB2LEV=DB2A //SYSREC DD DSN=SAMPLE.UFILEREF.SYSREC,DISP=(MOD,CATLG,CATLG), // UNIT=SYSDA,SPACE=(4000,(20,20),,,ROUND) //SYSERR DD DSN=SAMPLE.LOADXML3.STEP1.SYSERR, // DISP=(MOD,DELETE,CATLG),UNIT=SYSDA, // SPACE=(4000,(20,20),,,ROUND) //SYSDISC DD DSN=SAMPLE.LOADXML3.STEP1.SYSDISC, //SYSMAP DD DSN=SAMPLE.LOADXML3.STEP1.SYSMAP, //SYSUT1 DD DSN=SAMPLE.LOADXML3.STEP1.SYSUT1, //UTPRINT DD SYSOUT=* //SORTOUT DD DSN=SAMPLE.LOADXML3.STEP1.SORTOUT, //SYSIN DD * LOAD DATA INDDN SYSREC LOG NO REPLACE -- LOG NO will issue DBET state EBCDIC CCSID(00833,00933,00834) SORTKEYS INTO TABLE "ADMF001"."SAMPLETB" WHEN(00001:00002) = X'0003' ( "DSN_NULL_IND_00001" POSITION( ) CHAR(1) , "MYCOL1" POSITION( :00006) DECIMAL PACKED NULLIF(DSN_NULL_IND_00001)=X'FF' , "DSN_NULL_IND_00002" POSITION( ) CHAR(1) , "MYXML1" POSITION( ) VARCHAR CLOBF NULLIF(DSN_NULL_IND_00002)=X'FF' )

34 File References – LOAD from PDS (2/2)
LOAD DATA INDDN SYSREC LOG NO RESUME YES EBCDIC CCSID(00037,00000,00000) SORTKEYS INTO TABLE "ADMF001"."SAMPLETB“ WHEN(00001:00002) = X'0003‘ ( "DSN_NULL_IND_00001" POSITION( ) CHAR(1) , "MYCOL1" POSITION( :00006) DECIMAL PACKED NULLIF(DSN_NULL_IND_00001)=X'FF' , "DSN_NULL_IND_00002" POSITION( ) CHAR(1) , "MYXML1“ POSITION( ) VARCHAR CLOBF NULLIF(DSN_NULL_IND_00002)=X'FF' ) //LOADXML5 JOB 'USER=$$USER','<USERNAME:JOBNAME>',CLASS=A, // MSGCLASS=A,MSGLEVEL=(1,1),USER=ADMF001,REGION=4096K, // PASSWORD=ADMF001 /*ROUTE PRINT STLVM14.JOETANG //******************************************************************** //* COMMENT: //* //STEP1 EXEC DSNUPROC,UID='SAMPLE.LOADXML3',TIME=1440, // UTPROC='', // SYSTEM='SSTR',DB2LEV=DB2A //SYSREC DD DSN=SAMPLE.UFILEREF.SYSREC,DISP=(MOD,CATLG,CATLG), // UNIT=SYSDA,SPACE=(4000,(20,20),,,ROUND) //SYSERR DD DSN=SAMPLE.LOADXML3.STEP1.SYSERR, // DISP=(MOD,DELETE,CATLG),UNIT=SYSDA, // SPACE=(4000,(20,20),,,ROUND) //SYSDISC DD DSN=SAMPLE.LOADXML3.STEP1.SYSDISC, //SYSMAP DD DSN=SAMPLE.LOADXML3.STEP1.SYSMAP, //SYSUT1 DD DSN=SAMPLE.LOADXML3.STEP1.SYSUT1, //UTPRINT DD SYSOUT=* //SORTOUT DD DSN=SAMPLE.LOADXML3.STEP1.SORTOUT, //SYSIN DD * LOAD DATA INDDN SYSREC LOG NO REPLACE -- LOG NO will issue DBET state EBCDIC CCSID(00833,00933,00834) SORTKEYS INTO TABLE "ADMF001"."SAMPLETB" WHEN(00001:00002) = X'0003' ( "DSN_NULL_IND_00001" POSITION( ) CHAR(1) , "MYCOL1" POSITION( :00006) DECIMAL PACKED NULLIF(DSN_NULL_IND_00001)=X'FF' , "DSN_NULL_IND_00002" POSITION( ) CHAR(1) , "MYXML1" POSITION( ) VARCHAR CLOBF NULLIF(DSN_NULL_IND_00002)=X'FF' )

35 File References – UNLOAD to HFS
//CRTMNT EXEC PGM=BPXBATCH, // PARM='sh mkdir /u/sample; chmod 777 /u/sample; // chown sysadm /u/sample' //STEP1 EXEC PGM=BPXBATCH, // PARM='sh mkdir /u/sample/clobf‘ ... TEMPLATE TCLOBF DSN /u/sample/clobf DIR(5) DSNTYPE(HFS) UNLOAD TABLESPACE SAMPLEDB.SAMPLETS PUNCHDDN SYSPUNCH UNLDDN SYSREC FROM TABLE ADMF001.SAMPLETB ( MYCOL POSITION(*) DECIMAL(5,2) ,MYXML POSITION(*) VARCHAR CLOBF TCLOBF ) SAMPLE.UFILEREF.SYSREC: /u/sample/clobf/BI1OFEHQ /u/sample/clobf/BI1OFEH0 /u/sample/clobf/BI1OFEH1 /u/sample/clobf/BI1OFEIN /u/sample/clobf/BI1OFEIO //UNLOAFH JOB 'USER=$$USER','$$USER',CLASS=A, // MSGCLASS=A,MSGLEVEL=(1,1),USER=ADMF001, // PASSWORD=ADMF001,REGION=4096K /*ROUTE PRINT STLVM14.BATEMAN //******************************************************************** //* COMMENT: //* //STEP1 EXEC DSNUPROC,UID='SAMPLE.UNLFH', // UTPROC='', // SYSTEM='SSTR' //UTPRINT DD SYSOUT=* //SYSREC DD DSN=SAMPLE.TBSH.TLSULW01,DISP=(MOD,CATLG,CATLG), // UNIT=SYSDA,SPACE=(4000,(20,20),,,ROUND) //SYSPUNCH DD DSN=SAMPLE.UNLDH.STEP1.SYSPUNCH, // DISP=(MOD,CATLG,CATLG), //SYSUT1 DD DSN=SAMPLE.UNLDH.STEP1.SYSUT1, // DISP=(MOD,DELETE,CATLG), //SORTOUT DD DSN=SAMPLE.UNLDH.STEP1.SORTOUT, //SYSIN DD * TEMPLATE TCLOBF DSN /u/sample/clobf DIR(5) DSNTYPE(HFS) UNLOAD TABLESPACE SAMPLEDB.SAMPLETS PUNCHDDN SYSPUNCH UNLDDN SYSREC FROM TABLE ADMF001.SAMPLETB ( MYCOL POSITION(*) DECIMAL(5,2) ,MYXML POSITION(*) VARCHAR CLOBF TCLOBF ) /* $ cd /u/sample/clobf $ ls BI1OFEH0 BI1OFEH1 BI1OFEHQ BI1OFEIN BI1OFEIO

36 6. Use REORG and RUNSTATS REORG to make rows for the same documents clustered, when there are many updates and deletes. Use real-time stats SYSIBM.SYSTABLESPACESTATS and SYSINDEXSPACESTATS to derive heuristics (number of rows in XML TS is rows not documents) Use RUNSTATS to collects statistics for XML data and indexes so the optimizer can pick the right access methods LISTDEF DBACORDTSLIST INCLUDE TABLESPACES DATABASE DBACORD RUNSTATS TABLESPACE LIST DBACORDTSLIST TABLE(ALL) INDEX(ALL)

37 7. Backup and Recovery To recover base table space, take image copies of all related objects Use LISTDEF to define a list of related objects (QUIESCE not needed in V9) COPYTOCOPY may be used to replicate image copies of XML objects. MERGECOPY may be used to merge incremental copies of XML table spaces. Point in Time recovery (RECOVER TORBA, TOLOGPOINT) All related objects, including XML objects must be recovered to a consistent point in time Optional: CHECK utilities to validate base table spaces with XML columns, XML indexes and related XML table spaces. If there is an availability issue with one object in the related set, availability of the others may be impacted.

38 8. Diagnosing Problem Related to XML Objects
Identify XML tables and their related objects Run REPORT TABLESPACESET or query catalog tables Validate that the auxiliary index is consistent with the underlying table spaces Run CHECK INDEX on all indexes, DocID, NodeID and XML value indexes Validate the logical connection between the base table and XML table. Run CHECK DATA against the base table space. Use Repair to diagnose problem related to base table spaces with XML columns and their DocID index Use REPAIR LOCATE KEY to locate a row using DocID key in the DocID index Use Repair to diagnose problem related to XML table spaces and their NodeID index or XML Value Index Use REPAIR LOCATE RID to locate a row using a RID.

39 Checking data integrity
CHECK INDEX on DOCID, NODEID, XML indexes CHECK DATA on base tablespace SCOPE AUXONLY AUXERROR REPORT AUXERROR INVALIDATE XML table space XML table space 2 - CHECK INDEX NODEID Index XML Index Base table space DOCID Index 1 - CHECK INDEX Cols: DOCID NODEID XML Record Value Cols: DOCID XMLCOL 3 - CHECK DATA CHECK INDEX(2)

40 Correcting XML Data

41 9. Checking query plan CREATE TABLE ACORD.REQUEST (
ID BIGINT NOT NULL PRIMARY KEY, REQUESTXML XML, RESPONSEXML XML ) IN DATABASE DBACORD CREATE INDEX ACORD.ACORDINDEX1 ON ACORD.REQUEST(REQUESTXML) GENERATE KEYS USING XMLPATTERN 'declare default element namespace "http://ACORD.org/Standards/Life/2"; /TXLife/TXLifeRequest/TransRefGUID' as SQL VARCHAR(24) CREATE INDEX ACORD.ACORDINDEX2 ON ACORD.REQUEST(REQUESTXML) AS SQL VARCHAR(9)

42 Query plan (cont’ed) "http://ACORD.org/Standards/Life/2";
EXPLAIN PLAN SET QUERYNO = 101 FOR SELECT XMLQuery('declare default element namespace "http://ACORD.org/Standards/Life/2"; /TXLife/TXLifeRequest/OLifE/Holding/Policy/Life/Coverage/LifeParticipant' PASSING R.REQUESTXML), /TXLife/TXLifeRequest/OLifE/Party = /TXLife/TXLifeRequest/OLifE/ Holding/Policy/Life/Coverage/ ] ' PASSING R.REQUESTXML) FROM ACORD.REQUEST R WHERE XMLExists('declare default element namespace "http://ACORD.org/Standards/Life/2"; /TXLife/TXLifeRequest[TransRefGUID=" "]/ Find participant information about a policy. | PLANNO | ACCESSTYPE | MATCHCOLS | ACCESSCREATOR | ACCESSNAME | MIXOPSEQ | 1_| | M | | | | | 2_| | DX | | ACORD | ACORDINDEX | | 3_| | DX | | ACORD | ACORDINDEX | | 4_| | DI | | | | |

43 Steps in a picture 4 3 6 2 1 5 DOCID IDX NODEID IDX XML IDX1 XML IDX2
DOCID list 4 3 DOCID IDX INTERSECT DOCID list 1 DOCID list 2 RID list 6 2 5 NODEID IDX 1 XML IDX1 XML IDX2 Base Table

44 10. Performance Monitoring and Tuning
Since XML native storage is built on top of regular tablespace structure, there are no special changes in DB2 Performance Expert to support XML other than minor points - such as new XML locks. XML performance problem can be analyzed through accounting traces and performance traces. XML indexes have the same consideration as other indexes. The REORG utility should be used to maintain order and free space, if there are significant updates. Run RUNSTATS for statistics to help pick XML indexes.

45 Q & A Send questions to

46 Other DB2 pureXML Sessions at IOD
Introduction to DB2 pureXML: TAD-1485 Wed 2.00 Querying XML Data: An Introduction for SQL Developers TLU-1712 Thu 8.30 DB2 pureXML Introduction and Survival Guide TLU-1504 Thu Making the Transition to DB2 pureXML DB2 pureXML Customers: TLU-1197 Mon 3.45 DB2 pureXML Production Experiences at UCLA TLU-1533 Tue 8.30 Why Rational chose DB2 pureXML for Jazz REST Services and SOA solutions BGV-1659 Tue Implementing an Effective Electronic Government Solution - NY State Tax BHC-1677 Tue Improving Health Care in China With a DB2 XML EMR Solution BCS-1438 Tue 2.15 Learn How Verizon Streamlined their Order System TDZ-2146 Tue 2.15 Real-world Usage of pureXML BGV-1659 Tue 3.45 Using XML for Effective Cross-agency Shared Services in Public Security TLU-1993 Wed 8.30 Flowers and Financial Services: B2B With DB2 pureXML TLU-1437 Wed Implementing an Enterprise Order Database With DB2 pureXML at Verizon TAD-2255 Thu 8.30 DB2 and Data Studio: Building a Web Application Without the Web Application TLU-1678 Thu 3.30 DB2 pureXML Customers - Trends and Successes Meet the Expert: MTE Meet the Expert: Guogen Zhang MTE Meet the Expert: Henrik Loeser Meet The Experts: One-on-one, scheduled appointments between attendees and distinguished technical and business leaders from all segments. Attendee can discuss the topic of their choice.

47 Other DB2 pureXML Sessions at IOD
TAD-1906 Mon SOA and pureXML: The Role of DB2 in an Innovative Architecture TDZ Mon Query XML Data in DB2 9 for z/OS BGV-1661 Wed Streamline Govt Processing Through Electronic Forms and DB2 pureXML TLU-1622 Wed 2.00 Top 10 Best Practices for DB2 pureXML TDZ-1810 Fri Ten Essential DBA Tasks for DB2 9 for z/OS pureXML Birds of a Feather: BOF-1633 Thu DB2 pureXML Users - Best practices & Requirements BOF-1815 Thu DB2 9 for z/OS pureXML Real-world Experiences Hands-on Labs: HOL-1934 Tue EForms Application With DB2 pureXML and Lotus Forms HOL-2584 Wed DBA for pureXML in DB2 9 for z/OS HOL-2716 Wed Advanced DB2 pureXML HOL-1933 Thu pureXML Industry Applications HOL-2585 Thu Learning SQL/XML with CLP and SPUFI HOL-1923 Thu Demonstrating DB2 9.5 pureXML in an SOA Application Environment HOL-2583 Thu 2.00 Learning pureXML in DB2 9 for z/OS with IBM Data Studio HOL-1848 Fri Introduction to DB2 pureXML 9.5 Meet The Experts: One-on-one, scheduled appointments between attendees and distinguished technical and business leaders from all segments. Attendee can discuss the topic of their choice.

48 DB2 pureXML Resources Web site Wiki Forum Team Blog
Wiki Forum Team Blog ChannelDB2 User Group

49 X Join the IDUG Worldwide XML Contest
Five Contest Challenge Categories 1. Create a video 2. Write Xquery and SQL queries 3. Submit a database utility 4. Port an application 5. Write a pureXML application Enter the Contest here at the Conference Stop by the DB2 booth in the EXPO Create a Video and Submit it onsite- video cameras are available Take the Quick Quiz today at X Largest investment in XML community 200,000 Participants from 30 + countries Early Bird Prizes Laptops iPods Nintendo Wii and many more!

50 References on DB2 for z/OS pureXML
Introductory whitepaper: Leveraging DB2 9 for z/OS pureXML Technology (2nd Edition) Detailed introduction presentation: ftp://ftp.software.ibm.com/software/data/db2zos/presentations/2007/misc/purexml.pdf DB2 z/OS XML Guide: IBM developerWorks DB2 XML (LUW): Google pureXML wiki

51 Implicitly Created Objects
Create Table option Base table XML table DocID index NodeID index XML Index IN database. tablespace NM: given, DB: given, TS: given, ST: from DB BP: given or Deflt NM: G, DB: Base, TS: G, ST: from Base BP: Deflt/BP16K0 NM: G, TB: Base, IS: G, ST: from DB BP: Deflt/BP0 NM: G, TB: XML, IS: G, ST: from Base BP: Deflt/BP0 NM: given, TB: Base, IS: G, ST: given or DB BP: given or Deflt IN DATABASE database NM: given, DB: given, TS: G, ST: from DB NM: G, DB: Base, TS: G, ST: from Base NM: G, TB: Base, IS: G, ST: from DB NM: G, TB: XML, IS: G, ST: from Base TB: Base, IS: G, ST: given or DB IN tablespace NM: given, DB: DSNDB04, TS: given, ST: from TS NM: G, DB: DSNDB04, TS: G, ST: from Base NM: G, TB: Base, IS: G, ST: SYSDEFLT NM: given, TB: Base, IS: G, ST: given or SYSDEFLT none NM: given, DB: G, TS: G, ST:SYSDEFLT NM: G, DB: Base, TS: G, ST:SYSDEFLT NM: G, TB: XML, IS: G, ST: SYSDEFLT The two arrowed lines show that a DocID index is linked to the base table, and a NodeID index is linked the XML table. An XML index is similar to a regular index. NM: Name, TS: Table Space, ST: Stogroup, BP: Buffer pool, TB: Table, IS: Index Space, G: Generated.

52 DSSIZE for XML Table Space (future PTF)
PBG XML DSSIZE = 4GB (base is simple, SEG, or PBG) PBR XML DSSIZE based on base DSSIZE and page size Rationale: not to limit base table max number of partitions. Maxparitions can be altered for XML PBG TS independent of base table. SQL Ref

53 XML Related Locks New XML lock type, value ’35’x in instrumentation
Improvement under way PK28265 New XML lock type, value ’35’x in instrumentation SQL Base Page/Row Lock (Business as usual) XML Lock XML Table space Page Lock INSERT x page/row lock x lock, release at commit x page lock, release at commit UPDATE/DELETE u->x, s->x, x stays x SELECT UR, CS-CDN None s lock, release at next row fetch SELECT CS-CDY no workfile s page/row lock, release on next row fetch SELECT CS-CDY workfile s lock, release at close cursor SELECT UR, CS-CDN, CS-CDY with Multirow fetch and dynamic scrolling s page/row lock on rowset, release on next fetch s lock, release on next fetch SELECT RR, RS s page/row lock s lock, release at commit page latch (and optional P-Lock) page latch (and optional P-Lock)

54 Disclaimer © Copyright IBM Corporation [current year]. All rights reserved. U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. THE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY.  WHILE EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION CONTAINED IN THIS PRESENTATION, IT IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN ADDITION, THIS INFORMATION IS BASED ON IBM’S CURRENT PRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY IBM WITHOUT NOTICE.  IBM SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION. NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, NOR SHALL HAVE THE EFFECT OF, CREATING ANY WARRANTIES OR REPRESENTATIONS FROM IBM (OR ITS SUPPLIERS OR LICENSORS), OR ALTERING THE TERMS AND CONDITIONS OF ANY AGREEMENT OR LICENSE GOVERNING THE USE OF IBM PRODUCTS AND/OR SOFTWARE. IBM, the IBM logo, ibm.com, DB2, z/OS and pureXML are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both. If these and other IBM trademarked terms are marked on their first occurrence in this information with a trademark symbol (® or ™), these symbols indicate U.S. registered or common law trademarks owned by IBM at the time this information was published. Such trademarks may also be registered or common law trademarks in other countries. A current list of IBM trademarks is available on the Web at “Copyright and trademark information” at Other company, product, or service names may be trademarks or service marks of others.


Download ppt "Agenda Overview of pureXML in DB2 9 for z/OS"

Similar presentations


Ads by Google