I again used the following block of code for running my tests
declare l_result_xml XMLTYPE; l_ns_xml XMLTYPE; l_start NUMBER; l_end NUMBER; begin -- Build up the XML -- Has 2100+ row nodes ...snipped... l_start := dbms_utility.get_time; INSERT INTO LOAD_TEMP_RESULT VALUES l_result_xml; l_end := dbms_utility.get_time; dbms_output.put_line('INSERT INTO TEMP TIME in sec: ' || to_char((l_end - l_start) / 100)); l_start := dbms_utility.get_time; INSERT INTO import_queue (...20 columns...) SELECT CBIQ_ID_SEQ, CBRH_ID_SEQ, ...18 columns ... FROM LOAD_TEMP_RESULT ltr, XMLTABLE('/resultset/row' PASSING ltr.object_value -- column alias name COLUMNS CBIQ_ID_SEQ NUMBER(11) PATH 'CBIQ_ID_SEQ', CBRH_ID_SEQ NUMBER(11) PATH 'CBRH_ID_SEQ', ... 18 more columns ...); l_end := dbms_utility.get_time; dbms_output.put_line('INSERT INTO TIME in sec: ' || to_char((l_end - l_start) / 100)); rollback; end;
The only difference I changed was the CREATE TABLE statement for LOAD_TEMP_RESULT. The following table summarizes the various CREATE TABLE statements I used and the resulting times, where TEMP TIME is the output for "INSERT INTO TEMP TIME in sec:" and TIME is the output for "INSERT INTO TIME in sec:"
DDL | TEMP TIME (sec) | TIME (sec) |
---|---|---|
CREATE TABLE load_temp_result OF XMLTYPE; | 0.05 | 16 |
CREATE TABLE load_temp_result OF XMLTYPE XMLTYPE STORE AS BASICFILE CLOB; | 0.09 | 15.82 |
CREATE TABLE load_temp_result OF XMLTYPE XMLTYPE STORE AS SECUREFILE CLOB; | 2.36 | 15.46 |
CREATE TABLE load_temp_result OF XMLTYPE XMLTYPE STORE AS BASICFILE BINARY XML; | 0.27 | 0.63 |
CREATE TABLE load_temp_result OF XMLTYPE XMLTYPE STORE AS SECUREFILE BINARY XML; | 0.24 | 0.63 |
As I am using 11.1.0.6, the default behavior for this version of Oracle is to store XMLTypes as a CLOB. This is confirmed by the fact that the first row (default storage) matches most closely with the second row (explicit storage). Based on the results, it is easy to see that even creating a XMLType table (or a XMLType column) where the XMLType is stored as BINARY XML is well worth looking at in terms of performance when validation is not needed.
I'm not going to go into a discussion on the differences between BASICFILE and SECUREFILE, but the highlights of what SECUREFILE offers can be found at LOB Features Introduced in Oracle Database 11g Release 1. Oracle recommends that SECUREFILE be used for as I have picked up from the XML DB forum on OTN.
To recap the results from the previous two threads on this topic,
- Using XMLTable in a SQL statement to parse a PL/SQL XMLType variable took 1032 seconds (16+ minutes).
- Using PL/SQL to loop through each node in the XML and parse the information out and then INSERT that into a table took 4 seconds.
- Using a registered schema and associated table took 0.5 seconds.