• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Miracle Open World 2011  -  XML Index Strategies
 

Miracle Open World 2011 - XML Index Strategies

on

  • 2,314 views

 

Statistics

Views

Total Views
2,314
Views on SlideShare
2,232
Embed Views
82

Actions

Likes
1
Downloads
0
Comments
0

1 Embed 82

http://www.liberidu.com 82

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • It all comes down to packaging
  • Definitions of Structured, Semi-Structured and Unstructured data
  • Emp/Dept tables, Foreign/Primary Keys…Showing here ONLY 1 XML document…
  • See also OOW 2010, S317428: Building Really Scalable XML Applications with Oracle XML DB and Oracle Text – Nipun Agarwal, Oracle

Miracle Open World 2011  -  XML Index Strategies Miracle Open World 2011 - XML Index Strategies Presentation Transcript

  • XML Indexing StrategiesChoosing the Right Index for the Right Job
    Marco Gralike
  • Strange Chainsaw Tree Guy
    OakTable Member
    ACE Director
    Customer Advisory Board Member
    17+ years DBA, etc.
    Blog.gralike.com
    Technology.amis.nl
  • Richard Foote (Mr. Index)
    OakTable Member
    ACE Director
    Oracle Certified Professional
    22+ years DBA, etc.
    RichardFoote.wordpress.com
  • Refinement
  • Structured or Semi-Structured or…
    Structured
    Semi
    Structured
  • Unstructured Content
  • Document Driven / Data Driven
  • Design: Width and Height and …
    1
    3
    4
    5
    2
    X
    Y
    6
    Z
    Content Height: minOccurs="0" maxOccurs=“unbounded”
    Content Width: type="xs:string“, restriction…?
    Content Distribution: histogram, statistics, skew, cardinality ?
  • XMLType “Under the Hood”
    DOM Tree Model
    XQuery
    SQL/XML
    XMLType Abstraction
    Procedural XQuery
    DB XQuery
    XVM (use “no query rewrite”)
    XQuery Rewrite
    Pushdown
    SQL Execution
    XMLIndex
    Streaming XPath Evaluation
    RelationalAccess Methods
    Binary XML
    Object-Relational
    Relational Storage
    Secure Files
    Source OOW 2010 presentation S317428: Building Really Scalable XML Applications with Oracle XML DB and Oracle Text
  • XML Storage/Index Use Cases
    Binary XML
    (Schema based)
    XMLIndex Structured Component
  • XMLType
    In Memory
    (document)
    CLOB
    (document)
    Object Relational
    (data)
    Binary XML
    (data)
  • XMLType Storage Models
    CLOB
    Default until 11.2.0.2.0
    Non-Schema Based
    Binary XML
    Oracle 11 and Onwards
    Schema and Non-Schema Based
    Object Relational (+Hybrid)
    Nested Tables, Types, Varray’s
    Schema Based
  • Storage Index Defaults (xmltype)
    Binary XML / CLOB
    LOB Index
    Object Relational
    DBMS_XMLSCHEMA  “OPTIONS”
    Oracle 10g: Index Organized Tables
    Oracle 11g: B-Tree Indexes
    xdb:annotations
    Storage type xdb:SQLType
    Storage Typexdb:ColumnProps / xdb:TableProps
  • Index Methods (xmltype)
    CLOB
    • Oracle Text
    • XMLIndex (>= 11g)
    Binary XML
    • XMLIndex / Oracle Text
    • Virtual Columns (BTree)
    Object Relational
    • Standard Indexes
    • Oracle Text
  • Index Methods (10.x)
    BTree Index
    BTree I
    BT
    bookstore
    Oracle Text Index
    Function based Index (XPath)
    book
    whitepaper
    title
    author
    author
    chapter
    title
    author
    id
    paragraph
    content
    content
  • Function-Based Index
    Deprecated in 11.2
    Object Relational XMLType Storage
    (can be used, but shouldn’t, on CLOB)
    Performance wise the lesser option…
    SQL> CREATE INDEX function_based_index
    ON xml_data_table
    (extractValue(OBJECT_VALUE, '/Root/TextID'));
  • BTree / Bitmap Index (O.R.)
    Structured XML Data
    Ordered Collection Tables (OCT)
    ComplexTypes…
    “dot” notation using the “xmldata” pseudocolumn
    SQL> CREATE INDEX dot_notation_index
    ON xml_data_table
    ("XMLDATA". "TEXTID");
  • Syntax Index Alternatives
    SQL> CREATE INDEX function_based_again_idx
    ON xml_data_table
    (CAST("XMLDATA". "TEXTID“ as VARCHAR2(10)));
    SQL> CREATE INDEX oracle_11_applicable_only_index
    ON xml_data_tablexdt
    (XMLCast(XMLQuery
    ('$i/Root/TextID'
    PASSING xdt.OBJECT_VALUE as "i"
    RETURNING content)
    as VARCHAR2(10)));
  • Oracle Text Index
    Unstructured Data in XML
    CLOB storage XML part in Object Relational XML
    Secondary index on XMLIndex
    Can only index XML data TEXT nodes
    Result Set Interface (new in 11.2.0.2)
    Specify Query request and hit list requirements in XML
    SQL> CREATE INDEX oracle_text_index
    ON xml_data_table
    (OBJECT_VALUE) INDEXTYPE IS CTXSYS.CONTEXT;
  • Index Methods (11.1)
    BTree Index
    BTree I
    BT
    bookstore
    Secondary Oracle Text Index
    Function based Index (XPath)
    book
    whitepaper
    Unstructured
    XMLIndex
    title
    author
    author
    chapter
    title
    author
    id
    paragraph
    content
    content
  • XML Document contains:
    Semi Structured Data and Structured Data
    Supports searching and fragment extraction
    When XPath queried is not known beforehand
    XMLType CLOB or Binary XML content
    If you use an XMLIndex and/or combine it with Structured XMLIndex(es)
    Usage: Unstructured XMLIndex
  • Simple: Unstructured XMLIndex
    SQL> CREATEINDEXxmlindex_idx
    ON “XMLTYPE_COLUMN"(xdata)
    INDEXTYPEISXDB.XMLINDEX;
    Index created.
    SQL> CREATEINDEXxmlindex_idx
    ON “XMLTYPE_TABLE"(object_value)
    INDEXTYPEISXDB.XMLINDEX;
    Index created.
  • Creating Unstructured XMLIndex
    CREATEINDEXXMLIDX
    ON XMLBINARY_TAB (object_value)
    INDEXTYPEISXDB.XMLIndex
    PARAMETERS
    ('PATHS (INCLUDE (/ROOT/ID /ROOT/INFO/INFO_ID )
    NAMESPACEMAPPING(xmlns="http://localhost/xmlschema_bin.xsd") )
    PATH TABLE path_table(TABLESPACE XML_DATA)
    PATH ID INDEX pathid_idx (TABLESPACE XML_INDX)
    ORDER KEY INDEX orderkey_idx (TABLESPACE XML_INDX)
    VALUE INDEX    value_idx   (TABLESPACE XML_INDX)
    ASYNC (SYNC ALWAYS) STALE (FALSE) ')
    PARALLEL LOGGING;
  • Path Table
    PATH TABLE
    PATH INDEX
    • (PATHID, RID), BTREE
    ORDER INDEX
    • (RID, ORDER_KEY), BTREE
    VALUE INDEX
    • (SUBSTRB("VALUE",1,
    1599))
    • FUNCTION BASED
    SECONDAIRY INDEXES
    Unstructured
    XMLIndex
    f (x)
    Path Table
  • Unstructured XMLIndex (UXI)
    • OnePath Table
    • UsePath Subsetting
    • Full Blown XMLIndex canbe BIG
    • Token Tables (XDB.X$......)
    • Query re-writeonTokens
    • FuzzySearches, //
    • OptimizerStatistics
    • CanbemaintainedManually
    • Recorded inPending Table
    • Secondairyindexespossible
    Unstructured
    XMLIndex
    f (x)
    Path Table
  • Index Methods (11.2)
    BTree Index
    BTree I
    BT
    bookstore
    Secondary Oracle Text Index
    Function based Index (XPath)
    book
    whitepaper
    Structured
    XMLIndex
    Unstructured
    XMLIndex
    title
    author
    author
    chapter
    title
    author
    id
    paragraph
    content
    content
    Highly Structured
    Islands of Data
  • With highly Structured Data
    Likely candidates: ComplexTypes
    Structured Islands of Data
    Can be nested, but officially only one level
    XMLTABLE “virtual” nested column hint
    Will create (multiple) “Content Tables”
    Multiple XPath defined same columns with different purpose
    They deliver relational performance…!
    Usage: Structured XMLIndex
  • Simple: Structured XMLIndex
    “XMLTABLE” Driven Syntax
    SQL> CREATE INDEX xmlindex_sxi
    on xml_data_table (xmlcol)
    indextype is xdb.xmlindex
    parameters
    ('GROUP employee_info_group
    XMLTABLEEMP_CONTENT_TABLE
    ' '/employees/emp' '
    COLUMNS
    empidNUMBER(10) PATH ' 'id' ' ');
    Be aware
    ' '
  • Content Table(s)
    KEY INDEX
    • (KEY)
    • Unique BTREE Index
    • PrimaryKey
    RID INDEX
    • (RID)
    • NON Unique BTREE Index
    Your Columns
    RID
    rowid
    YOUR
    column
    X
    Key
    RAW
    Not null
    RID
    rowid
    Key
    RAW
    Not null
    YOUR
    columns
    X
    CONTENT TABLE(s)
    YOUR
    columns
    X
    RID
    rowid
    Key
    RAW
    Not null
  • Structured XMLIndex (SXI)
    Content Table(s)
    BasedonXMLTABLEsyntax
    XMLTable construct canbenestedbut:
    “Only ONE XMLType column allowed”
     VIRTUAL column
    CanbemaintainedManually
    Secondairyindexespossible
    LOCAL parameter (partitioning)
    Structured
    XMLIndex
    f (x)
    Content
    Tables
  • Adding Structured Indexes
    SQL> ALTER INDEX xmlindex_sxi
    parameters
    ('ADD_GROUP
    GROUP my_new_group
    XMLTABLE xml_content_tab_new
    ' '/root/extra' '
    COLUMNS
    extracol VARCHAR2(35) PATH ' 'new_element' ' ');
  • Mixed XMLIndex Options
    bookstore
    Secondary (text)Index
    Unstructured
    XMLIndex
    book
    whitepaper
    Structured
    XMLIndex
    Structured
    XMLIndex
    title
    author
    author
    paragraph
    title
    author
    id
    chapter
    content
    content
  • Mixed XMLIndex structures
    CREATE INDEX xmlindex on TEST_RANGE_XML (doc)
    indextype is xdb.xmlindex
    PARAMETERS
    (' PATH TABLE path_table PATHS (EXCLUDE(/root/ElementInfo)) ');
    BEGIN
    DBMS_XMLINDEX.registerParameter
    ('StructuredXML',
    'ADD_GROUP GROUP ElementInfo
    XMLTABLExml_cnttable_valueinfo ' '/root/ElementInfo' '
    COLUMNS ValueInfo VARCHAR2(100) PATH ' 'ValueInfo' ');
    END; /
    ALTER INDEX xmlindex PARAMETERS('PARAM StructuredXML');
  • XMLIndex Maintenance
    ALTER INDEX
    XMLIndex Parameter Changes
    DBMS_XMLINDEX.DROPPARAMETER
    DBMS_XMLINDEX.MODIFYPARAMETER
    DBMS_XMLINDEX.REGISTERPARAMETER
    Manual Synchronizing an XMLIndex
    DBMS_XMLINDEX.SYNCINDEX
    Pending Tables
  • “There Can Be Only One…”
  • Syntax Awareness
    SYNC=ALWAYS
    Mandatory when Combined XMLIndex
    SYNC=MANUAL
    Locking
    STALE=FALSE | TRUE
    Hmmm…
    Empty XMLIndex tables
    OOPS  I got my “XMLTABLE” Syntax etc. “wrong”
  • Notes on XMLIndex (1)
    Only ONE XMLIndex is allowed in a user schema
    Add extra XMLIndex structures (structured or unstructured)
    via ADD_GROUP syntax
    Only SYNC=ALWAYS is allowed while using mixed XMLIndex structures or add more than one
  • Notes on XMLIndex (2)
    You need the LOCAL parameter to create local partitioned XMLIndexes
    An XMLIndex on a HASH partitioned XMLType column or XMLType table, isnot (yet) allowed
    But you can create an Oracle Text Index on such structures
  • Recap
    True understanding of Storage
    and Index options will provide:
    Optimal performance
    Out perform XML (Java based)
    A lot of choice:
    Problems are Complex
    Also provides Solutions
    Good design beforehand is the path to success
  • References (1)
    Oracle Whitepapers
    Oracle XML DB : Choosing the Best XMLType Storage Option for Your Use Case (PDF)
    Oracle XML DB : Best Practices to Get Optimal Performance out of XML Queries (PDF)
    Blog
    http://blog.gralike.com
    (Dedicated XMLDB blog)
    Semi-Structured XMLIndex section
    Structured XMLIndex section
  • References (2)
    Oracle Open World Presentationon XML DB
    S317428: Building Really Scalable XML Applications with Oracle XML DB and Oracle Text
    XML DB OTN / FAQ Thread
    http://forums.oracle.com/forums/forum.jspa?forumID=34
    http://forums.oracle.com/forums/thread.jspa?threadID=410714