Marco Gralike
Management Consultant 
• Ordina, The Netherlands 
• Oracle 20+ years experience 
• Oracle ACE Director (www.xmldb.nl)
What do we use in the 
database…
VARCHAR NVARCHAR NUMBER INTEGER FLOAT DECIMAL CHAR VARCHAR2 
NVARCHAR2 NCHAR VARYING VARCHAR DATE REAL DOUBLE PRECISION 
UNSIGNED BINARY INTEGER(8) UNSIGNED BINARY INTEGER(16) UNSIGNED 
BINARY INTEGER(32)SIGNED BINARY INTEGER(8)SIGNED BINARY 
INTEGER(16)SIGNED BINARY INTEGER(32)POINTER BINARY ROWID RAW CHAR 
BINARY_FLOAT BINARY FLOAT BINARY DOUBLE LONG RAW LONG UB2 LONG 
SB4 MLSLABEL XMLTYPE (TABLE or REF) BINARY_DOUBLE PL/SQL REF 
CURSOR UROWID KOKED1 KOTTBX KOTTB KOTMI KOTMD KOTADX KOTAD KOTTD 
KOKED REF CLOB BLOB BFILE TYPE (USER-DEFINED) TYPE (TABLE OF 
RECORD) TYPE (VARRAY) CFILE TIME TIME WITH TZ TIMESTAMP TIMESTAMP 
WITH TZ INTERVAL YEAR TO MONTH INTERVAL DAY TO SECOND NAMED 
COLLECTION NAMED OBJECT TIMESTAMP WITH LOCAL TZ OCTET SMALLINT 
VARYING ARRAY TABLE PL/SQL RECORD PL/SQL COLLECTION PL/SQL 
BOOLEAN OID CONTIGUOUS ARRAY CANONICALLOB POINTER PL/SQL POSITIVE 
PL/SQL POSITIVEN PL/SQL ROWID PL/SQL LONG PL/SQL LONG RAW PL/SQL 
BINARY INTEGER PL/SQL PLS INTEGER PL/SQL NATURAL PL/SQL NATURALN 
PL/SQL STRING...
Datatype moto: 
If incorrect datatype you will have a decrease in performance or 
you get the incorrect results ( if you are lucky 8))...
*) The In-Memory Maria Option
What can we do in XMLType 
land… (fast recap / intro)
Unstructured 
XMLIndex 
Structured 
XMLIndex 
Structured 
XMLIndex 
XML Text Index 
paragraph 
book 
title author author 
whitepaper 
title author id 
content 
bookstore 
chapter 
content
Unstructured 
XMLIndex 
f (x) 
Path Table
Structured 
XMLIndex 
f (x) 
Content 
Tables
CREATE INDEX LINEITEMS_XI 
ON PURCHASEORDER_T_BIN (XML_COLUMN) 
INDEXTYPE IS "XDB"."XMLINDEX" 
PARAMETERS (' GROUP LINEITEMS_GROUP 
XMLTABLE LINEITEM_SXI_T 
(inmemory memcompress for query priority critical) 
''/PurchaseOrder/LineItems/LineItem'' 
COLUMNS 
lineitem VARCHAR2(30) PATH ''@ItemNumber'', 
description VARCHAR2(100) PATH ''Part/@Description'', 
partid VARCHAR2(30) PATH ''Part'', 
unitprice VARCHAR2(30) PATH ''Part/@UnitPrice'', 
quantity VARCHAR2(30) PATH ''Quantity'' 
');
Unstructured 
XMLIndex 
Structured 
XMLIndex 
Structured 
XMLIndex 
XML Text Index 
paragraph 
book 
title author author 
whitepaper 
title author id 
content 
bookstore 
chapter 
content
Parallelization 
XMLType  12.1
Setup
10.000 
45263
In Memory / XML Storage Tests 
 CLOB – Securefile 
 XMLType – Securefile Binary XML 
 XMLType – Securefile Binary XML (XSD) 
 XMLType – Object Relational (XSD – Default) 
 XMLType – Object Relational (XSD – Out of line XML)
SQL> alter table PURCHASEORDER_T 
inmemory memcompress for query priority critical; 
SQL> alter table LINEITEMS_T 
inmemory memcompress for query priority critical; 
SQL> create TABLE... 
inmemory memcompress for query priority critical; 
SQL> create INDEX ... INDEXTYPE IS "XDB"."XMLINDEX" 
inmemory memcompress for query priority critical;
In Memory / XML Index Tests 
 Securefile Binary XML - In Memory Structured Index 
 Securefile Binary XML (XSD) – In Memory Structured Index 
 Object Relational (XSD – Default) 
 Object Relational (XSD – Out of line XML)
In Memory / XML Query’s 
“Arbitrary queries” 
 Query 1 - Touching PurchaseOrder and LineItems 
 Query 2 - Touching PurchaseOrder and LineItems & group/count 
 Query 3 - Touching LineItems elements and attributes only
Findings & Graphics…
SQL> SELECT * 
FROM XMLTABLE 
('for $i in fn:collection("oradb:/IM/PURCHASEORDER_T”) 
/PurchaseOrder[ CostCenter = $CC 
and Requestor = $REQUESTOR 
and count(LineItems/LineItem) > $QUANTITY 
]/Reference 
RETURN $i 
' 
passing 'A60' as "CC" 
, 'Diana Lorentz' as "REQUESTOR" 
, 5 as "QUANTITY" 
);
COLUMN_VALUE 
------------------------------------------------------- 
<Reference>DLORENTZ-20120411133920295PDT</Reference> 
<Reference>DLORENTZ-20120206180918983PST</Reference> 
<Reference>DLORENTZ-20121219144418724PST</Reference> 
<Reference>DLORENTZ-20120710194550792PDT</Reference> 
<Reference>DLORENTZ-20120723165626922PDT</Reference> 
<Reference>DLORENTZ-20120728151113368PDT</Reference> 
<Reference>DLORENTZ-20120602200119333PDT</Reference> 
<Reference>DLORENTZ-20120513165042874PDT</Reference> 
... 
...
varray, nested table (default)
out of line
*) Unoptimized XML construct 
detected 
(enable XMLOptimizationCheck for 
more information)
*) Collection Iterator Pickler Fetch 
XMLSEQUENCEFROMXMLTYPE 
XQSEQUENCEFROMXMLTYPE
*) Tracing ORA-19022 
SET XMLOptimizationCheck ON 
Event = “19027 trace name context forever, level 0x2000” 
Event = “10053 trace name context forever, level 1”
SQL> SELECT t1.Country 
, t2.Part 
, min(t2.Quantity) as quantity 
, count(*) as occurrence 
FROM PURCHASEORDER_T_X pt 
, XMLTABLE('/PurchaseOrder' 
PASSING pt.{xmltype} 
COLUMNS 
Country PATH 'ShippingInstructions/Address/country', 
x_lineitems XMLTYPE PATH 'LineItems/LineItem' ) t1 
, XMLTABLE(’*' 
PASSING t1.x_lineitems 
COLUMNS 
Part PATH 'Part', 
Quantity PATH 'Quantity' ) t2 
WHERE t1.Country is NOT NULL 
AND t1.Country = 'United Kingdom' 
HAVING count(*) >= 10 
GROUP BY t1.Country, t2.Part 
ORDER BY t1.Country;
COUNTRY PART QUANTITY OCCURRENCE 
--------------- ------------ -------- ---------- 
United Kingdom 56775022792 1 11 
United Kingdom 43396799493 1 10 
United Kingdom 717951000866 1 10 
United Kingdom 13023046696 1 11 
United Kingdom 25192024825 1 10 
5 rows selected.
SQL> SELECT lines.lineitem, 
lines.description, 
lines.partid, 
lines.unitprice, 
lines.quantity 
FROM purchaseorder_t pt, 
XMLTable('/PurchaseOrder/LineItems/LineItem' 
PASSING xmltype_table_or_column 
COLUMNS 
lineitem PATH '@ItemNumber', 
description PATH 'Part/@Description', 
partid PATH 'Part', 
unitprice PATH 'Part/@UnitPrice', 
quantity PATH 'Quantity’ 
) lines;
LINEITEM DESCRIPTION PARTID UNITPRICE QTY 
-------- ------------------------------------------ ----------- --------- --- 
2 The Longest Yard 97360870848 27,95 5 
1 Babe / Babe- Pig In the City 25192141621 19,95 4 
3 Down to You 71795100742 19,95 3 
2 I Spy: Tag, You're It 14381983920 19,95 4 
4 Dragon Fist 43396071711 19,95 3 
1 Multiplicity 43396824492 19,95 9 
4 Things You Can Tell Just By Looking At Her 27616859198 19,95 3 
... 
... 
45263 rows selected
SQL> SELECT lines.lineitem, 
lines.description, 
lines.partid, 
lines.unitprice, 
lines.quantity 
FROM purchaseorder_t pt, 
XMLTable('/PurchaseOrder/LineItems/LineItem' 
PASSING xmltype_table_or_column 
COLUMNS 
LINES_RNO FOR ORDINALITY, 
lineitem PATH '@ItemNumber', 
description PATH 'Part/@Description', 
partid PATH 'Part', 
unitprice PATH 'Part/@UnitPrice', 
quantity PATH 'Quantity’ 
) lines;
Recap…
• In-Memory Column Store can achieve extra performance 
• In-Memory Column Store can be applied selectively (column) 
• Optimization possible – “RID” (for ordinality) 
• Optimizer XML Costs not yet on par (costs <> timings) 
• “Old rules-of-thumb” for XMLType still apply

UKOUG Tech14 - Using Database In-Memory Column Store with Complex Datatypes

  • 1.
  • 2.
    Management Consultant •Ordina, The Netherlands • Oracle 20+ years experience • Oracle ACE Director (www.xmldb.nl)
  • 3.
    What do weuse in the database…
  • 4.
    VARCHAR NVARCHAR NUMBERINTEGER FLOAT DECIMAL CHAR VARCHAR2 NVARCHAR2 NCHAR VARYING VARCHAR DATE REAL DOUBLE PRECISION UNSIGNED BINARY INTEGER(8) UNSIGNED BINARY INTEGER(16) UNSIGNED BINARY INTEGER(32)SIGNED BINARY INTEGER(8)SIGNED BINARY INTEGER(16)SIGNED BINARY INTEGER(32)POINTER BINARY ROWID RAW CHAR BINARY_FLOAT BINARY FLOAT BINARY DOUBLE LONG RAW LONG UB2 LONG SB4 MLSLABEL XMLTYPE (TABLE or REF) BINARY_DOUBLE PL/SQL REF CURSOR UROWID KOKED1 KOTTBX KOTTB KOTMI KOTMD KOTADX KOTAD KOTTD KOKED REF CLOB BLOB BFILE TYPE (USER-DEFINED) TYPE (TABLE OF RECORD) TYPE (VARRAY) CFILE TIME TIME WITH TZ TIMESTAMP TIMESTAMP WITH TZ INTERVAL YEAR TO MONTH INTERVAL DAY TO SECOND NAMED COLLECTION NAMED OBJECT TIMESTAMP WITH LOCAL TZ OCTET SMALLINT VARYING ARRAY TABLE PL/SQL RECORD PL/SQL COLLECTION PL/SQL BOOLEAN OID CONTIGUOUS ARRAY CANONICALLOB POINTER PL/SQL POSITIVE PL/SQL POSITIVEN PL/SQL ROWID PL/SQL LONG PL/SQL LONG RAW PL/SQL BINARY INTEGER PL/SQL PLS INTEGER PL/SQL NATURAL PL/SQL NATURALN PL/SQL STRING...
  • 5.
    Datatype moto: Ifincorrect datatype you will have a decrease in performance or you get the incorrect results ( if you are lucky 8))...
  • 11.
    *) The In-MemoryMaria Option
  • 12.
    What can wedo in XMLType land… (fast recap / intro)
  • 17.
    Unstructured XMLIndex Structured XMLIndex Structured XMLIndex XML Text Index paragraph book title author author whitepaper title author id content bookstore chapter content
  • 18.
  • 21.
    Structured XMLIndex f(x) Content Tables
  • 23.
    CREATE INDEX LINEITEMS_XI ON PURCHASEORDER_T_BIN (XML_COLUMN) INDEXTYPE IS "XDB"."XMLINDEX" PARAMETERS (' GROUP LINEITEMS_GROUP XMLTABLE LINEITEM_SXI_T (inmemory memcompress for query priority critical) ''/PurchaseOrder/LineItems/LineItem'' COLUMNS lineitem VARCHAR2(30) PATH ''@ItemNumber'', description VARCHAR2(100) PATH ''Part/@Description'', partid VARCHAR2(30) PATH ''Part'', unitprice VARCHAR2(30) PATH ''Part/@UnitPrice'', quantity VARCHAR2(30) PATH ''Quantity'' ');
  • 24.
    Unstructured XMLIndex Structured XMLIndex Structured XMLIndex XML Text Index paragraph book title author author whitepaper title author id content bookstore chapter content
  • 25.
  • 26.
  • 28.
  • 29.
    In Memory /XML Storage Tests  CLOB – Securefile  XMLType – Securefile Binary XML  XMLType – Securefile Binary XML (XSD)  XMLType – Object Relational (XSD – Default)  XMLType – Object Relational (XSD – Out of line XML)
  • 30.
    SQL> alter tablePURCHASEORDER_T inmemory memcompress for query priority critical; SQL> alter table LINEITEMS_T inmemory memcompress for query priority critical; SQL> create TABLE... inmemory memcompress for query priority critical; SQL> create INDEX ... INDEXTYPE IS "XDB"."XMLINDEX" inmemory memcompress for query priority critical;
  • 31.
    In Memory /XML Index Tests  Securefile Binary XML - In Memory Structured Index  Securefile Binary XML (XSD) – In Memory Structured Index  Object Relational (XSD – Default)  Object Relational (XSD – Out of line XML)
  • 32.
    In Memory /XML Query’s “Arbitrary queries”  Query 1 - Touching PurchaseOrder and LineItems  Query 2 - Touching PurchaseOrder and LineItems & group/count  Query 3 - Touching LineItems elements and attributes only
  • 33.
  • 35.
    SQL> SELECT * FROM XMLTABLE ('for $i in fn:collection("oradb:/IM/PURCHASEORDER_T”) /PurchaseOrder[ CostCenter = $CC and Requestor = $REQUESTOR and count(LineItems/LineItem) > $QUANTITY ]/Reference RETURN $i ' passing 'A60' as "CC" , 'Diana Lorentz' as "REQUESTOR" , 5 as "QUANTITY" );
  • 36.
    COLUMN_VALUE ------------------------------------------------------- <Reference>DLORENTZ-20120411133920295PDT</Reference> <Reference>DLORENTZ-20120206180918983PST</Reference> <Reference>DLORENTZ-20121219144418724PST</Reference> <Reference>DLORENTZ-20120710194550792PDT</Reference> <Reference>DLORENTZ-20120723165626922PDT</Reference> <Reference>DLORENTZ-20120728151113368PDT</Reference> <Reference>DLORENTZ-20120602200119333PDT</Reference> <Reference>DLORENTZ-20120513165042874PDT</Reference> ... ...
  • 37.
  • 39.
  • 40.
    *) Unoptimized XMLconstruct detected (enable XMLOptimizationCheck for more information)
  • 41.
    *) Collection IteratorPickler Fetch XMLSEQUENCEFROMXMLTYPE XQSEQUENCEFROMXMLTYPE
  • 42.
    *) Tracing ORA-19022 SET XMLOptimizationCheck ON Event = “19027 trace name context forever, level 0x2000” Event = “10053 trace name context forever, level 1”
  • 44.
    SQL> SELECT t1.Country , t2.Part , min(t2.Quantity) as quantity , count(*) as occurrence FROM PURCHASEORDER_T_X pt , XMLTABLE('/PurchaseOrder' PASSING pt.{xmltype} COLUMNS Country PATH 'ShippingInstructions/Address/country', x_lineitems XMLTYPE PATH 'LineItems/LineItem' ) t1 , XMLTABLE(’*' PASSING t1.x_lineitems COLUMNS Part PATH 'Part', Quantity PATH 'Quantity' ) t2 WHERE t1.Country is NOT NULL AND t1.Country = 'United Kingdom' HAVING count(*) >= 10 GROUP BY t1.Country, t2.Part ORDER BY t1.Country;
  • 45.
    COUNTRY PART QUANTITYOCCURRENCE --------------- ------------ -------- ---------- United Kingdom 56775022792 1 11 United Kingdom 43396799493 1 10 United Kingdom 717951000866 1 10 United Kingdom 13023046696 1 11 United Kingdom 25192024825 1 10 5 rows selected.
  • 51.
    SQL> SELECT lines.lineitem, lines.description, lines.partid, lines.unitprice, lines.quantity FROM purchaseorder_t pt, XMLTable('/PurchaseOrder/LineItems/LineItem' PASSING xmltype_table_or_column COLUMNS lineitem PATH '@ItemNumber', description PATH 'Part/@Description', partid PATH 'Part', unitprice PATH 'Part/@UnitPrice', quantity PATH 'Quantity’ ) lines;
  • 52.
    LINEITEM DESCRIPTION PARTIDUNITPRICE QTY -------- ------------------------------------------ ----------- --------- --- 2 The Longest Yard 97360870848 27,95 5 1 Babe / Babe- Pig In the City 25192141621 19,95 4 3 Down to You 71795100742 19,95 3 2 I Spy: Tag, You're It 14381983920 19,95 4 4 Dragon Fist 43396071711 19,95 3 1 Multiplicity 43396824492 19,95 9 4 Things You Can Tell Just By Looking At Her 27616859198 19,95 3 ... ... 45263 rows selected
  • 57.
    SQL> SELECT lines.lineitem, lines.description, lines.partid, lines.unitprice, lines.quantity FROM purchaseorder_t pt, XMLTable('/PurchaseOrder/LineItems/LineItem' PASSING xmltype_table_or_column COLUMNS LINES_RNO FOR ORDINALITY, lineitem PATH '@ItemNumber', description PATH 'Part/@Description', partid PATH 'Part', unitprice PATH 'Part/@UnitPrice', quantity PATH 'Quantity’ ) lines;
  • 59.
  • 60.
    • In-Memory ColumnStore can achieve extra performance • In-Memory Column Store can be applied selectively (column) • Optimization possible – “RID” (for ordinality) • Optimizer XML Costs not yet on par (costs <> timings) • “Old rules-of-thumb” for XMLType still apply