Presentation is loading. Please wait.

Presentation is loading. Please wait.

4/17/2015 DB2 9 – A DBA Guide to Native XML. Agenda and Purpose XML it looks easy enough XML in DB2 9 XML testing 1 2 3 XML and Performance Summary and.

Similar presentations


Presentation on theme: "4/17/2015 DB2 9 – A DBA Guide to Native XML. Agenda and Purpose XML it looks easy enough XML in DB2 9 XML testing 1 2 3 XML and Performance Summary and."— Presentation transcript:

1 4/17/2015 DB2 9 – A DBA Guide to Native XML

2 Agenda and Purpose XML it looks easy enough XML in DB2 9 XML testing 1 2 3 XML and Performance Summary and Questions Understand XML and related technology DB2 9 implementation of native XML Have an idea how it looks in the real world Performance and design considerations for XML Be able to discuss options for DB2 XML applications

3 Why Pure XML o85% of information is unstructured o50 separate systems and 2 -3 ERP in average company o30% of people’s time is spent searching for relevant information 40 Exabyte's (4 x 10 to the 19th) of unique information will be generated in 2007

4 Why XML 85% of information is unstructured XML can represent just about anything XML forces syntax-Level interoperability Information outlives technology Information Outlives Technology

5 XML Overview › XML stands for Extensible Markup Language › XML is a markup language much like HTML › XML was designed to describe data › XML tags are not predefined. You must define your own tags › XML uses a XML Schema (XSD) to describe the data (DTD older technology) › XML is a W3C Recommendation

6 XML Description - TAGS Mike Sniezek BMC Software (713) 918-8800

7 XML Validation XSD XML SCHEMA XML DOCUMENT Mike Sniezek BMC Software (713) 918-8800

8 XML Transformation › XSL consists of three parts: –XSLT - a language for transforming XML documents –XPath - a language for navigating in XML documents –XSL-FO - a language for formatting XML documents XML DocumentXSL Style sheetParameters XSL Transformation EmailXMLTextSQLXHTMLWMLHTML

9 XML Data - Spread sheet used for examples

10 XML Data from Spreadsheet Empire Burlesque Bob Dylan USA Columbia 10.90 1985 Hide your heart Bonnie Tyler UK CBS Records 9.90 1988

11 XML Display with XLS <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> Title Artist TitleArtist Empire Burlesque Bob Dylan

12 Using XML the Big Picture Apples http://www.w3.org/2001/12/soap-encoding 1.90 miracle

13 XML and DB2 v9

14 XML Data type / storage Tablespace Table XML Tablespace XML Table XML columnDOCID NODEIDXMLDATA DOCID Index DOCID, NODEID Index XML User Index CREATE TABLE FAVORITE_CDS (NAME CHAR(20) NOT NULL, CDID BIGINT, CDINFO XML); XML Tablespace Partitioned by growth, if the base table space is not partitioned Partitioned by range, if the base table space is partitioned

15 SYSXMLRELS TBOWNER TBNAME COLNAME XML TABLE MKTMBS CLIENTS CONTACTINFO XCLIENTS MKTMBS FAVORITE CDINFOXFAVORITE_CDS MKTMBS PURCHASEORDERS XMLPOXPURCHASEORDERS Base Table XML Table XML columnDOCID NODEIDXMLDATA SYSIBM.SYSXMLRELS

16 SYSXMLSTRINGS SELECT FROM "SYSIBM".SYSXMLSTRINGS WHERE STRINGID > 1142 STRINGID STRING 1143 TITLE 1144 ARTIST 1145 COMPANY 1146 YEAR 1147 CD NUMBER OF ROWS SELECTED 5 Empire Burlesque Bob Dylan USA Columbia 10.90 1985 Hide your heart Bonnie Tyler UK CBS Records 9.90 1988 1143Hide your heart1143

17 Just going through the basics

18 Getting to DB2 9 ------------------------------ Commands Entered ----------------------- ------- connect to DEDK user MVSMXS1 using ********; ------------------------------------------------------------------------------ connect to DEDK user MVSMXS1 using Database Connection Information Database server = DB2 OS/390 9.1.5 SQL authorization ID = MVSMXS1 Local database alias = DEDK A JDBC connection to the target has succeeded.

19 XML Data Type – Purchase Orders Alice Smith 123 Maple Street Mill Valley CA 90952 Robert Smith 8 Oak Avenue Old Town PA 95819 Hurry, my lawn is going wild Lawnmower 1 148.95 Confirm this is electric Baby Monitor 1 39.98 1999-05-21

20 DDL - Nothing To Worry About CREATE TABLESPACE relData pagesize 4K managed by automatic storage bufferpool bp4k; DROP TABLE PURCHASEORDERS; CREATE TABLE PurchaseOrders (ponumber varchar(10) not null, podate date not null, status char(1), XMLpo xml, primary key (ponumber)); CREATE TABLE PO LIKE PurchaseOrders; CREATE VIEW ValidPurchaseOrders as SELECT ponumber, podate, XMLpo FROM PurchaseOrders WHERE status = ‘A’; ALTER TABLE PurchaseOrders ADD revisedXMLpo xml;

21 Manipulation UPDATE PurchaseOrders SET XMLpo = :XMLpo_revised WHERE ponumber = ‘12345’; INSERT INTO PurchaseOrders VALUES (‘200300001’,CURRENT DATE, ‘A’, :xmlPo); INSERT INTO PurchaseOrders VALUES (‘200300003’, CURRENT DATE, ‘A’, XMLPARSE(DOCUMENT :vchar PRESERVE WHITESPACE) ); INSERT into PurchaseOrders VALUES( '200300004', CURRENT DATE, 'A',DSN_XMLValidate(:lobPo, ’SYSXSR.myPOSchema’)); DELETE FROM PurchaseOrders WHERE ponumber = ‘12345’

22 Retrieval SELECT XMLpo INTO :xmlPo FROM PurchaseOrders WHERE ponumber = ‘200300001’; SELECT XMLPO FROM PurchaseOrders WHERE XMLEXISTS(‘//items/item[productName = “Baby Monitor”]’ PASSING XMLpo); SELECT XMLQUERY(‘//items/item/quantity’ PASSING XMLpo) FROM PurchaseOrders WHERE …;

23 Indexes CREATE INDEX ON PurchaseOrders(XMLPO) Generate Keys Using XMLPATTERN ‘/purchaseOrder/items/item/productName’ as SQL VARCHAR(100); Index will be used for this query. SELECT XMLPO FROM PurchaseOrders XMLEXISTS(‘/purchaseOrder/items/item[productName = “Lawnmower”]’ passing XMLPO)

24 Validation XML Schema Support DB2 requires a SQL identifier for identification. REGISTER XMLSCHEMA http://www.test.com/order.xsd FROM file://C:/xmlschema/order.xsd AS ORDERSCHEMA COMPLETE [ENABLE DECOMPOSITION]; REMOVE XMLSCHEMA ORDERSCHEMA;

25 XML Performance How are you going to use the XML?

26 INSERT Performance INSERT › The obvious the larger and more complex the XML column is the more expensive the insert. › The more indexes the more overhead › INSERT with VALIDATE is at least double the overhead › Use host variables rather than Literals › Use LOAD instead of SQL INSERT (30 to 40 percent)

27 Update › When updating an XML document, an SQL UPDATE statement is equivalent to performing an SQL DELETE and INSERT and the performance will be about the same. › If this is going to happen allot then consider splitting the XML into smaller pieces

28 Select Performance › Performance for SQL no real change, the size and complexity of the XML document will determine overhead. Well coded SQL proper indexes and physical design still make the big difference. › XML Indexes are different and good ones make a great deal of difference. CREATE INDEX ON PurchaseOrders(XMLPO) Generate Keys Using XMLPATTERN ‘/purchaseOrder/items/item/productName’ as SQL VARCHAR(100);

29 Data Considerations CREATE TABLE CD_CATALOG (TITLE VARCHAR(30), ARTIST VARCHAR(30), COUNTRY VARCHAR(25), COMPANY VARCHAR (25) PRICE DECIMAL(5,2), YEAR SMALINT); CREATE TABLE CD_CATALOG (PID VARCHAR(10) NOT NULL, OWNER VARCHAR(30), DESCRIPTION XML); CREATE TABLE CD_CATALOG (NAME CHAR(20) NOT NULL, CDID BIGINT, CDINFO XML, PRIMARY KEY (NAME)); Native XML is good when you need Schema flexibility Search Performance Partial document retrieval

30 Summary › XML is the current standard for sharing data › How your organization is exploiting XML or will be exploiting XML should be understood by Database Administrators › You should be familiar of how DB2 9 stores and catalogs the XML data type › You don’t have to be an SQL GURU but be aware of performance characteristics › Even if your organization has no immediate plans to use the XML data type your understanding maybe key to the future of new applications. – Try it! › If you have questions mike_sniezek@bmc.com

31 Some useful links › http://www.eccnet.com/acronyms/acronyms.php - related acronyms http://www.eccnet.com/acronyms/acronyms.php › http://www.w3schools.com/xml/default.asp - XML Tutorial http://www.w3schools.com/xml/default.asp › http://www.w3.org/TR/xml/ - XML 1.0 Standard: http://www.w3.org/TR/xml/ › http://www.w3.org/TR/xpath-datamodel/ - XPATH and XQUERY http://www.w3.org/TR/xpath-datamodel/ › http://www.w3.org/TR/xmlschema-0/ - Schema http://www.w3.org/TR/xmlschema-0/ › http://xml.coverpages.org/xmlApplications.html - XML applications and standards http://xml.coverpages.org/xmlApplications.html › http://www.w3schools.com/xpath/default.asp -XPATH Tutorial http://www.w3schools.com/xpath/default.asp › http://www.redbooks.ibm.com/redbooks/pdfs/sg247330.pdf -Red Book http://www.redbooks.ibm.com/redbooks/pdfs/sg247330.pdf › http://www.w3schools.com/xml/xml_examples.asp - examples http://www.w3schools.com/xml/xml_examples.asp


Download ppt "4/17/2015 DB2 9 – A DBA Guide to Native XML. Agenda and Purpose XML it looks easy enough XML in DB2 9 XML testing 1 2 3 XML and Performance Summary and."

Similar presentations


Ads by Google