Ctxsys.context index on registered schema xmltype column
9iR2
Is it possible to create a text index (indextype is ctxsys.context) on a schema registered xmltype column?
I tried it, the index creation works fine.
After the first insert statement the Oracle process seems to hang. (CPU 100%, increasing memory consumption)
Yes, I previously entered some data.
Test case:
1. register schema
begin
DBMS_XMLSCHEMA.REGISTERSCHEMA('http://localhost/JobPositionSeeker-1_1.xsd',
getDocument('JobPositionSeeker-1_1.xsd'), TRUE, TRUE, FALSE, FALSE
end;
2. create table
CREATE TABLE application_xml of XMLType
XMLSCHEMA "http://localhost/JobPositionSeeker-1_1.xsd" ELEMENT "JobPositionSeeker"
3. entered some data
4. created the index
create index applicant on application_xml ( SYS_NC_ROWINFO$)
indextype is ctxsys.context
5. select using index
select value(a).getClobVal() from application_xml a
where contains( value(a),'%ai% INPATH(//PersonalData/PersonName/FamilyName)')>0
6. insert another record
-> crash
Similar Messages
-
Error in Updating ctxsys.context index using ctxsrv
Environment :
Linux 6.2,
Oracle 8.1.6
character set : zhs16gbk or zhs16cgb231280
I can create an ctxsys.context index(using CHINESE_VGRAM_LEXER) on a long column, and i can rebuild this index with no parameters.
When i want to rebuild this index automatic using ctxsrv, this error occur ---
DRG-50857 Oracle error in drtldml(dml)
Ora-2000 error
anybody can help me?
nullthe complete error:
Dml batch: cid=1023
End batch: return code is 1
DRG-50857: oracle error in drtldml(dml)
ORA_20000: interMedia text 4mNs
DRG-50857: oracle error in drsxsopen
ORA-01480: STR83V51dA?H1IY?U:sW:
null -
Hi,
in the following enviroment:
Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
With the Partitioning option
JServer Release 9.0.1.1.1 - Production
On an MS 2K box
I experience the following problem:
if I create a table
create table test(c type);
where type is varchar2 o clob I then succesfully issue this
command:
create index test_ctx on test(c) indextype is ctxsys.context;
but if type is sys.XMLType I get :
ORA-01031: insufficient privileges.
Any suggestion
Thanks
AlexUnder user sys as sysdba the following happens:
SQL> create table test(c XMLType);
Table created.
SQL> create index test_ctx on test(c) indextype is
ctxsys.context;
create index test_ctx on test(c) indextype is ctxsys.context
ERROR at line 1:
ORA-29855: error occurred in the execution of ODCIINDEXCREATE
routine
ORA-20000: Oracle Text error:
DRG-50857: oracle error in drixtab.create_index_tables
ORA-00955: name is already used by an existing object
ORA-06512: at "CTXSYS.DRUE", line 157
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 176 -
How to define ctxsys.context index for an ORDDoc column
I need to use Oracle Text to search on a column that is of type ORDsys.OrdDoc. Can someone point me in the direction of an example please - I note someone pointed out that a USER_DATASTORE is the way to go, but what do I need to put it it? I also wish to use Word to HTML feature of the INSO_FILTER if at all possible.
thanks
BrigetteHi Brian,
I don't know how to do this with a SQL query (as the OrdDoc may not be displayable say in SQLPlus), but if you check out the samples at http://otn.oracle.com/sample_code/products/intermedia/htdocs/intermedia_servlet_jsp_samples/imedia_servlet_jsp_readme.htm
there is a JAva Servlet that works nicely. If you are not a Java person, there are other samples at http://otn.oracle.com/sample_code/products/intermedia/index.html
keep smiling
Brigette -
Suggestion: Oracle text CONTEXT index on one or more columns ?
Hi,
I'm implementing Oracle text using CONTEXT ..... and would like to ask you for performance suggestion ...
I have a table of Articles .... with columns .. TITLE, SUBTITLE , BODY ...
Now is it better from performance point of view to move all three columns into one dummy column ... with name like FULLTEXT ... and put index on this single column,
and then use CONTAINS(FULLTEXT,'...')>0
Or is it almost the same for oracle if i put indexes on all three columns and then call:
CONTAINS(TITLE,'...')>0 OR CONTAINS(SUBTITLE,'...')>0 OR CONTAINS(BODY,'...')>0
I actually don't care if the result is a match in TITLE OR SUBTITLE OR BODY ....
So if i move into some FULLTEXT column, then i have duplicate data in a article row ... but if i create indexes for each column, than oracle has 2x more to index,optimize and search ... am I wright ?
Table has 1.8mil records ...
Thank you.
Krismackrispi wrote:
Now is it better from performance point of view to move all three columns into one dummy column ... with name like FULLTEXT ... and put index on this single column,
and then use CONTAINS(FULLTEXT,'...')>0What version of Oracle are you on? If 11 then you could use a virtual column to do this, otherwise you'd have to write code to maintain the column which can get messy.
mackrispi wrote:
Or is it almost the same for oracle if i put indexes on all three columns and then call:
CONTAINS(TITLE,'...')>0 OR CONTAINS(SUBTITLE,'...')>0 OR CONTAINS(BODY,'...')>0Benchmark it and find out :)
Another option would be something like this.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:9455353124561
Were i you, i would try out those 3 approaches and see which meet your performance requirements and weigh that with the ease of implementation and administration. -
Question: create index indextype is ctxsys.context whith NOLOGGING
Dear All,
I would like to ask a question about
CREATE INDEX <index_name> ON <table_name> ( <index_col> ) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS ( ... )maybe you experienced that ctxsys.context index creation takes long time.
When you create a ctxsys.context index it is obvious to reduce the workload of the RDBMS. In this case I would like to reduce the I/O load with NOLOGGING option.
Firstly, I try to put the index into a tablespace with no logging option. I don't know why but it is not working. Watching the alert.log file I diagnose that redo log generated simultaneously while index generated (there are no other activity on RDBMS).
Q1 (optional): Why generating redo on object of NOLOGGING tablaspace ?
I think there are better solution: use the NOLOGGIN option of the create index command which is very simple to use at column indexes.
Which unclear to me how should I use in CREATE INDEX .. INDEXTYPE IS CTXSYS.CONTEXT command.
Fllowing the CREATE INDEX command syntax seems oubvious - but it provides sytax error.
Maybe this is why CREATE INDEX .. INDEXTYPE IS CTXSYS.CONTEXT needs something different for options: PL/SQL
example captured (for options):
begin
ctx_ddl.create_preference ('mystore', 'BASIC_STORAGE');
ctx_ddl.set_attribute ('mystore', 'I_INDEX_CLAUSE', 'tablespace users storage (initial 32k) compress 2');
end;
CREATE INDEX docs_idx ON my_docs(doc) INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS ('STORAGE mystore');Q: How can I specify NOLOGGING option? In the index command? In the attribute? What is the exact syntax if NOLOGGING is allowed at ctxsys.context?
Oracle version: 11.1.0.6.0
Any advice, highly appreciated.
IstvanYou have to specify nologging in storage preference.
See Avoiding Redo Logging for an Oracle Text Domain Index (Doc ID 432762.1)
Example:
begin
ctx_ddl.drop_preference('my_storage');
end;
begin
ctx_ddl.create_preference('my_storage','BASIC_STORAGE');
end;
begin
ctx_ddl.set_attribute('my_storage', 'i_table_clause','tablespace foo1 storage (initial 5M next 10M pctincrease 0 freelists 24 freelist groups 24) nologging');
ctx_ddl.set_attribute('my_storage', 'k_table_clause','tablespace foo2 storage (initial 5M next 10M pctincrease 0) nologging');
ctx_ddl.set_attribute('my_storage', 'r_table_clause','tablespace foo3 storage (initial 5M next 10M pctincrease 0) lob(DATA) store as (nocache nologging) nologging');
ctx_ddl.set_attribute('my_storage', 'n_table_clause','tablespace foo4 storage (initial 5M next 10M pctincrease 0) nologging');
ctx_ddl.set_attribute('my_storage', 'p_table_clause','tablespace foo5 storage (initial 5M next 10M pctincrease 0) nologging');
ctx_ddl.set_attribute('my_storage', 'i_index_clause','tablespace foo6 storage (initial 5M next 10M pctincrease 0) compress 2 nologging');
end; -
Oracle Text, ctxsys.context problem with number column
Hi,
DB 11.2.0.3
Is there any solution to create ctxsys.context index on number column ? Or I have to create other index type ?
When I try do that (create ctxsys.context index), I get
09:01:18 ORA-29855: wystąpił błąd przy wykonywaniu podprogramu ODCIINDEXCREATE (An error has occurred in the performance of the subprogram)
09:01:18 ORA-20000: Oracle Text - błąd: (- error:)
09:01:18 DRG-10509: niepoprawna kolumna tekstowa: ITEM_TYPE (invalid text column:)
09:01:18 ORA-06512: przy "CTXSYS.DRUE", linia 160
09:01:18 ORA-06512: przy "CTXSYS.TEXTINDEXMETHODS", linia 366Btw, is there possible to search like "*LIKE %123%*" clause any of index (in contains) ?
Edited by: Ndejo on 2012-11-21 00:53The multi_column_datastore says that the text to be indexed should be fetched from the supplied COLUMNS list rather than from the actual column the index is created on.
So in this case we're fetching the contents of "theNumber" column, converting it to text, and indexing it.
You don't necessarily need a dummy column, if "a_title" is a varchar column you could create the index on that instead.
For example:
SQL> create table mytab( a_id number, a_code number, a_title varchar2(80), a_subtitle varchar2(80), a_info clob );
Table created.
SQL> insert into mytab values ( 12, 9812376, 'foo is the title',
2 'foobar is the subtitle', 'the info column will not be indexed' );
1 row created.
SQL> exec ctx_ddl.drop_preference( 'myds' )
PL/SQL procedure successfully completed.
SQL> exec ctx_ddl.create_preference( 'myds', 'MULTI_COLUMN_DATASTORE' )
PL/SQL procedure successfully completed.
SQL> exec ctx_ddl.set_attribute( 'myds', 'COLUMNS', 'a_code, a_title, a_subtitle' )
PL/SQL procedure successfully completed.
SQL> create index myindex on mytab (a_title) indextype is ctxsys.context
2 parameters ('datastore myds');
Index created.
SQL> select a_id from mytab where contains (a_title, '%123%') > 0;
A_ID
12
SQL> select a_id from mytab where contains (a_title, 'foo') > 0;
A_ID
12If you want to be able to search within a particular column, then add "section group CTXSYS.AUTO_SECTION_GROUP" to the parameters clause, and you can then do:
SQL> select a_id from mytab where contains (a_title, 'foobar WITHIN a_subtitle') > 0;
A_ID
12 -
Faster Context index creation!!
Hi Experts,
I am new to the concept of CONTEXT in Oracle and I havent worked on it. My problem is that we have monthly process of rebuilding the context index on a table ( varchar column). This process takes about 8hrs. When I created it the last time I increased the sort_area_size parameter for the session to 500M,increased sort_multiblock_read_count and db_file_multiblock_read_count depending upon the OS limitations,and the index was created in 4 hrs. But this is just DBA trick to do things faster and i beleive it can be done more faster.
Can anyone suggest me what are the ways of speeding up the index creation process from the CONTEXT perspective
,like increasing default memory with Ctx_Adm.Set_Parameter ( 'DEFAULT_INDEX_MEMORY', '500M'); .
Also having default_index_memory and sort_area_size as 500, will this take 1000M of memory during the index creation?
Also i read somewhere that before creating index truncating the table DR$INDEX_ERROR will help speeding index creation. Is this right? I think it should not make a difference .
Any suggestion on speeding up the index creation would be helpful. i cannot create the index in parallel as I am running Oracle 8.1.6 and base table is not partitioned.
Thanks.
AnkurSorry for posting this question here. I have put in on TEXT forum.
-
Indextype is ctxsys.context
hi all,
i've a problem with index with ctxsys.context index
i created it on a table has a field (description of a certain component)
the field's type is VARCHAR2(256)
The query performed is
select count(*) from Loaded_Table_Test
where contains(F8,'%Resistor%') > 0;
it returns many records
THE PROBLEM IS
after many days of perfoming the same query it seems like its
not working :the query returns nothing
I wounder if anybody can help me,Thanks in advance
Rasha FayezDoes it return an error message? If you're doing this in a application,
try it in SQL*Plus to see.
Most likely reason for this is that you're getting "query too complex".
This could start happening, even though the query used to work, if more records
have been added to the table and therefore increased the number of
expansions for '%resistor%'.
Double truncation like this is not generally a good idea. Even if you don't
get the 'query too complex error', the query will perform poorly unless you
have the SUBSTRING_INDEX option in use.
- Roger -
XMLType column based on XML Schema: several questions
Hi,
I've a table on an oracle db version 10.1.0.4 where I stage the xml files containing orders created on a third party's system using BizTalk.
Although the storage I opted for is based on an XML Schema, defined by this third-party, I am facing big perfomance issues with files bigger than a few hundreds of kBs.
For instance, a 32Mb file takes more than 2 hours to be processed.
Now, after reading other threads in this forum and the documentation, my understanding of the problem is that the whole issue is with the correct indexing of the nested tables.
Here is my current XML Schema definition:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xdb:storeVarrayAsTable="true">
<xs:include schemaLocation="private/Types.xsd"/>
<xs:element name="PickData">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="ProdRun">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="Nr" type="xs:int"/>
<xs:element name="Date" type="string8"/>
<xs:element name="Final" type="xs:int"/>
<xs:element name="PickWave" maxOccurs="unbounded">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="Nr" type="string10"/>
<xs:element name="ProdLine" type="string2"/>
<xs:element name="TourSeq" type="xs:int"/>
<xs:element name="Tour" type="string20"/>
<xs:element name="Customer" maxOccurs="unbounded">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="Seq" type="string20"/>
<xs:element name="Cust" type="string10"/>
<xs:element name="Mod" type="string30"/>
<xs:element name="Tod" type="string30"/>
<xs:element name="InvOrder" maxOccurs="unbounded">
<xs:complexType xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="Nr" type="string20"/>
<xs:element name="Item" type="string20"/>
<xs:element name="Qty" type="xs:int"/>
<xs:element name="Priority" type="xs:int"/>
<xs:element name="Reordering" type="xs:int"/>
<xs:element name="DelDate" type="string8"/>
<xs:element name="HlOrder" type="string20"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="InvOrderKey">
<xs:selector xpath="InvOrder"/>
<xs:field xpath="Nr"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="CustomerKey">
<xs:selector xpath="Customer"/>
<xs:field xpath="Seq"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="PickWaveKey">
<xs:selector xpath="PickWave"/>
<xs:field xpath="Nr"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="ProdRunKey">
<xs:selector xpath="ProdRun"/>
<xs:field xpath="Nr"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Here is the included sub-schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="string2">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="2"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string5">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="5"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string6">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="6"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string8">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="8"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string10">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="10"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string15">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="15"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string20">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="20"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string30">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="30"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string40">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="40"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string50">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="string250">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="250"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
The statement for creating my table is
CREATE TABLE "XML_ORDERS"
("ID" NUMBER(7,0) NOT NULL ENABLE,
"XMLFILE" "SYS"."XMLTYPE" ,
"INSERTED" DATE DEFAULT sysdate,
CONSTRAINT "XML_ORDERS_PK" PRIMARY KEY ("ID") USING INDEX ENABLE
) XMLTYPE COLUMN XMLFILE STORE AS OBJECT RELATIONAL
XMLSCHEMA "private/PickData.xsd" ELEMENT "PickData"
Here is a simple instance document:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<PickData xsi:noNamespaceSchemaLocation="private/PickData.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ProdRun>
<Nr>5</Nr>
<Date>15112005</Date>
<Final>1</Final>
<PickWave>
<Nr>IPW0000017</Nr>
<ProdLine>01</ProdLine>
<TourSeq>1</TourSeq>
<Tour>00000043_078</Tour>
<Customer>
<Seq>5</Seq>
<Cust>100000006</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000457</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000742</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000459</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000742</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>6</Seq>
<Cust>100000013</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000461</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000743</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000463</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000743</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>2</Seq>
<Cust>100000114</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000465</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000744</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000467</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000744</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>3</Seq>
<Cust>100000140</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000469</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000745</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000471</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000745</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>7</Seq>
<Cust>100000143</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000473</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000746</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000475</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000746</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>8</Seq>
<Cust>100000145</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000477</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000747</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000479</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000747</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>9</Seq>
<Cust>100000146</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000481</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>0</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000748</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000483</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000748</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>4</Seq>
<Cust>100000147</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000485</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>0</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000750</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000487</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000750</HlOrder>
</InvOrder>
</Customer>
<Customer>
<Seq>10</Seq>
<Cust>100000148</Cust>
<Mod>FO</Mod>
<Tod>DDU</Tod>
<InvOrder>
<Nr>IIO0000489</Nr>
<Item>100000036</Item>
<Qty>20</Qty>
<Priority>0</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000751</HlOrder>
</InvOrder>
<InvOrder>
<Nr>IIO0000491</Nr>
<Item>100000045</Item>
<Qty>20</Qty>
<Priority>1</Priority>
<Reordering>0</Reordering>
<DelDate>15112005</DelDate>
<HlOrder>CSO000751</HlOrder>
</InvOrder>
</Customer>
</PickWave>
</ProdRun>
</PickData>
When I registered the XMLSchema, the following types and tables were automatically created and you can see the hierarchy below:
(by the way, I could not find any xdb_utilities.printNestedTables mentioned elsewhere)
XML_ORDERS
|_PickData381_T
|___ProdRun382_T
|_____PickWave388_COLL
|_______PickWave383_T
|_________Customer387_COLL
|___________Customer384_T
|_____________InvOrder386_COLL
These objects are then used in the following nested tables:
TABLE_NAME TABLE_TYPE_NAME PARENT_TABLE_NAME PARENT_TABLE_COLUMN
SYS_NTaK/5zar5S0WitSsgu6OKPQ== PickWave388_COLL PickData389_TAB "XMLDATA"."ProdRun"."PickWave"
SYS_NTf6QvwVm8SFKz+K/YYWq+WQ== Item408_COLL ProdData409_TAB "XMLDATA"."Item"
SYS_NTtu05ilrRQqmuEN4k+07VDA== Customer402_COLL OutboundParty403_TAB "XMLDATA"."Customer"
SYS_NTK6fhWq5uTJ+vKcgBpNm1Fg== InvOrder386_COLL SYS_NTIIzv7bkXQSSS43igtfi5eg== InvOrder
SYS_NTIIzv7bkXQSSS43igtfi5eg== Customer387_COLL SYS_NTaK/5zar5S0WitSsgu6OKPQ== Customer
I enabled sql tracing and I got the following TKPROF output
INSERT INTO IMP_ORDERS (PICK_INVORDERNR, PICK_ITEM, PICK_QTY, PICK_PRIORITY,
PICK_REORDERING, PICK_HLORDER, PICK_DELDATE, PICK_CUST, PICK_MOD, PICK_TOD,
PICK_SEQ, PICK_PICKWAVENR, PICK_PICKWAVEPRODLINE, PICK_PICKWAVETOUR,
PICK_PICKWAVETOURSEQ, PICK_ORDKEY, PICK_RUNKEY) SELECT INVORDERNR, ITEM,
QTY, PRIORITY, REORDERING, HLORDER, DELDATE, CUST, MOD, TOD, SEQ,
PICKWAVENR, PICKWAVEPRODLINE, PICKWAVETOUR, PICKWAVETOURSEQ, ROWNUM AS
PICK_ORDKEY, PRODRUNID FROM (SELECT /*+ cardinality(g 15)*/
EXTRACTVALUE(VALUE(G), '/InvOrder/Nr') AS INVORDERNR, EXTRACTVALUE(VALUE(G),
'/InvOrder/Item') AS ITEM, EXTRACTVALUE(VALUE(G), '/InvOrder/Qty') AS QTY,
EXTRACTVALUE(VALUE(G), '/InvOrder/Priority') AS PRIORITY,
EXTRACTVALUE(VALUE(G), '/InvOrder/Reordering') AS REORDERING,
EXTRACTVALUE(VALUE(G), '/InvOrder/HlOrder') AS HLORDER,
TO_DATE(EXTRACTVALUE(VALUE(G), '/InvOrder/DelDate'),'DDMMYYYY') AS DELDATE,
F.CUST, F.MOD, F.TOD, F.SEQ, F.PICKWAVENR, F.PICKWAVEPRODLINE,
F.PICKWAVETOUR, F.PICKWAVETOURSEQ, F.PRODRUNNR, F.PRODRUNDATE,
F.PRODRUNFINAL, F.PRODRUNID FROM (SELECT /*+ cardinality(e 60)*/VALUE(E) AS
CUSTOMERNODE, EXTRACTVALUE(VALUE(E), '/Customer/Cust') AS CUST,
EXTRACTVALUE(VALUE(E), '/Customer/Mod') AS MOD, EXTRACTVALUE(VALUE(E),
'/Customer/Tod') AS TOD, TO_NUMBER(EXTRACTVALUE(VALUE(E), '/Customer/Seq'))
AS SEQ, D.PICKWAVENR, D.PICKWAVEPRODLINE, D.PICKWAVETOUR, D.PICKWAVETOURSEQ,
D.PRODRUNNR, D.PRODRUNDATE, D.PRODRUNFINAL, D.PRODRUNID FROM (SELECT /*+
cardinality(c 100)*/VALUE(C) AS PICKWAVENODE, EXTRACTVALUE(VALUE(C),
'/PickWave/Nr') AS PICKWAVENR, TO_NUMBER(EXTRACTVALUE(VALUE(C),
'/PickWave/ProdLine')) AS PICKWAVEPRODLINE, EXTRACTVALUE(VALUE(C),
'/PickWave/Tour') AS PICKWAVETOUR, TO_NUMBER(EXTRACTVALUE(VALUE(C),
'/PickWave/TourSeq')) AS PICKWAVETOURSEQ, A.PRODRUNNR, A.PRODRUNDATE,
A.PRODRUNFINAL, A.PRODRUNID FROM (SELECT /*+ cardinality(b 1)*/VALUE(B) AS
PRODRUNNODE, EXTRACTVALUE(VALUE(B), '/ProdRun/Nr') AS PRODRUNNR,
TO_DATE(EXTRACTVALUE(VALUE(B), '/ProdRun/Date'),'DDMMYYYY') AS PRODRUNDATE,
EXTRACTVALUE(VALUE(B), '/ProdRun/Final') AS PRODRUNFINAL, X.ID PRODRUNID
FROM XML_ORDERS X, TABLE(XMLSEQUENCE(EXTRACT(X.XMLFILE,'/PickData/ProdRun'))
) B WHERE X.ID = :B1 ) A, TABLE(XMLSEQUENCE(EXTRACT(A.PRODRUNNODE,
'/ProdRun/PickWave'))) C ) D, TABLE(XMLSEQUENCE(EXTRACT(D.PICKWAVENODE,
'/PickWave/Customer'))) E ) F, TABLE(XMLSEQUENCE(EXTRACT(F.CUSTOMERNODE,
'/Customer/InvOrder'))) G ORDER BY PICKWAVEPRODLINE, PICKWAVETOURSEQ,
PICKWAVENR, SEQ )
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 4324.09 9994.65 0 57193 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 2 4324.09 9994.65 0 57193 0 0
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 68 (recursive depth: 1)
Rows Row Source Operation
0 COUNT (cr=0 pr=0 pw=0 time=180 us)
0 VIEW (cr=0 pr=0 pw=0 time=166 us)
0 SORT ORDER BY (cr=0 pr=0 pw=0 time=152 us)
40866 NESTED LOOPS (cr=54973 pr=0 pw=0 time=31065606 us)
1363 NESTED LOOPS (cr=54937 pr=0 pw=0 time=11037183 us)
1 NESTED LOOPS (cr=54889 pr=0 pw=0 time=10145883 us)
1 NESTED LOOPS (cr=54841 pr=0 pw=0 time=9799012 us)
1 TABLE ACCESS BY INDEX ROWID XML_ORDERS (cr=2 pr=0 pw=0 time=222 us)
1 INDEX UNIQUE SCAN XML_ORDERS_PK (cr=1 pr=0 pw=0 time=126 us)(object id 58551)
1 COLLECTION ITERATOR PICKLER FETCH (cr=54839 pr=0 pw=0 time=9798748 us)
1 COLLECTION ITERATOR PICKLER FETCH (cr=48 pr=0 pw=0 time=346818 us)
1363 COLLECTION ITERATOR PICKLER FETCH (cr=48 pr=0 pw=0 time=870830 us)
40866 COLLECTION ITERATOR PICKLER FETCH (cr=36 pr=0 pw=0 time=18739302 us)
Note that I cancelled this operation before it was over so I imagine that these figures refer to the statistics as of the time when the operation was interrupted.
So, here are finally my questions.
In order to create the constraints on the nested tables as shown in other threads, do I need to drop the existing xml_orders table and ancillary object types and recreate them or is there a way to add such constraints using the existing system generated object names?
Secondly, the xml_orders table may contain severale documents, not just one and his current primary key is the column ID. So, in order to uniquely identify the deepest element in the xml document, I need first to select the relevant document by means of the id column.
Would it be better to create the indexes containing this id column together with the nested_table_id and array_index?
Thanks for you help.
Flavio
PS: I wrote a 10 lines xsl transformation that I passed on to Saxon together with the 32Mb file. It took less than 1 minute to produce a flat file that was loaded almost instantly by SQL*Loader. So, what I am looking for is a procedure loading this stuff in less than 2 minutes or possibly less.Does the following help
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:53 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> spool registerSchema_&4..log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> declare
2 result boolean;
3 begin
4 result := dbms_xdb.createResource('/home/&1/xsd/&4',
5 bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
6 end;
7 /
old 4: result := dbms_xdb.createResource('/home/&1/xsd/&4',
new 4: result := dbms_xdb.createResource('/home/OTNTEST/xsd/GetaxTypes.xsd',
old 5: bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
new 5: bfilename(USER,'GetaxTypes.xsd'),nls_charset_id('AL32UTF8'));
PL/SQL procedure successfully completed.
SQL> commit
2 /
Commit complete.
SQL> alter session set events='31098 trace name context forever'
2 /
Session altered.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 schemaURL => '&3',
5 schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
6 local => TRUE,
7 genTypes => TRUE,
8 genBean => FALSE,
9 genTables => &5
10 );
11 end;
12 /
old 4: schemaURL => '&3',
new 4: schemaURL => 'private/GetaxTypes.xsd',
old 5: schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
new 5: schemaDoc => xdbURIType('/home/OTNTEST/xsd/GetaxTypes.xsd').getClob(),
old 9: genTables => &5
new 9: genTables => TRUE
PL/SQL procedure successfully completed.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:55 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> spool registerSchema_&4..log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> declare
2 result boolean;
3 begin
4 result := dbms_xdb.createResource('/home/&1/xsd/&4',
5 bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
6 end;
7 /
old 4: result := dbms_xdb.createResource('/home/&1/xsd/&4',
new 4: result := dbms_xdb.createResource('/home/OTNTEST/xsd/PickData.xsd',
old 5: bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
new 5: bfilename(USER,'PickData.xsd'),nls_charset_id('AL32UTF8'));
PL/SQL procedure successfully completed.
SQL> commit
2 /
Commit complete.
SQL> alter session set events='31098 trace name context forever'
2 /
Session altered.
SQL> begin
2 dbms_xmlschema.registerSchema
3 (
4 schemaURL => '&3',
5 schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
6 local => TRUE,
7 genTypes => TRUE,
8 genBean => FALSE,
9 genTables => &5
10 );
11 end;
12 /
old 4: schemaURL => '&3',
new 4: schemaURL => 'private/PickData.xsd',
old 5: schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
new 5: schemaDoc => xdbURIType('/home/OTNTEST/xsd/PickData.xsd').getClob(),
old 9: genTables => &5
new 9: genTables => TRUE
PL/SQL procedure successfully completed.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:58 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> spool createTable.log
SQL> --
SQL> connect &1/&2
Connected.
SQL> --
SQL> CREATE TABLE "XML_ORDERS"
2 ("ID" NUMBER(7,0) NOT NULL ENABLE,
3 "XMLFILE" "SYS"."XMLTYPE" ,
4 "INSERTED" DATE DEFAULT sysdate,
5 CONSTRAINT "XML_ORDERS_PK" PRIMARY KEY ("ID") USING INDEX ENABLE
6 ) XMLTYPE COLUMN XMLFILE STORE AS OBJECT RELATIONAL
7 XMLSCHEMA "private/PickData.xsd"
8 ELEMENT "PickData"
9 VARRAY XMLFILE."XMLDATA"."ProdRun"."PickWave" STORE AS TABLE PickWave_TAB
10 (
11 ( primary key (nested_table_id, array_index)
12 ) organization index overflow
13 VARRAY "Customer" STORE AS TABLE Customer_TAB
14 (
15 (primary key (nested_table_id, array_index)
16 ) organization index overflow
17 VARRAY "InvOrder" STORE AS TABLE InvOrder_TAB
18 (
19 (primary key (nested_table_id, array_index)
20 ) organization index overflow
21 )
22 )
23 )
24 /
Table created.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:59 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> spool insertFile_&3..log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> set timing on
SQL> set long 10000
SQL> --
SQL> insert into XML_ORDERS (ID, XMLFILE) values (&4, xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
2 /
old 1: insert into XML_ORDERS (ID, XMLFILE) values (&4, xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
new 1: insert into XML_ORDERS (ID, XMLFILE) values (10, xmltype(bfilename(USER,'testcase.xml'),nls_charset_id('AL32UT
8')))
1 row created.
Elapsed: 00:00:00.11
SQL> commit
2 /
Commit complete.
Elapsed: 00:00:00.01
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 27 21:44:59 2005
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> spool testcase.log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> set timing on
SQL> set long 10000
SQL> set pages 0 lines 140
SQL> --
SQL> -- Testcase code here
SQL> --
SQL> set autotrace on explain
SQL> --
SQL> create or replace view PROD_RUN_VIEW
2 (
3 PRODRUNNODE,
4 PRODRUNNR,
5 PRODRUNDATE,
6 PRODRUNID,
7 PRODRUNFINAL
8 )
9 as
10 select EXTRACT(XMLFILE,'/PickData/ProdRun'),
11 EXTRACTVALUE(XMLFILE , '/PickData/ProdRun/Nr'),
12 TO_DATE(EXTRACTVALUE(XMLFILE, '/PickData/ProdRun/Date'),'DDMMYYYY'),
13 ID,
14 EXTRACTVALUE(XMLFILE,'/PickData/ProdRun/Final')
15 from XML_ORDERS
16 /
View created.
Elapsed: 00:00:00.09
SQL> create or replace view PICK_WAVE_VIEW
2 (
3 PICKWAVENODE,
4 PICKWAVENR,
5 PICKWAVEPRODLINE,
6 PICKWAVETOUR,
7 PICKWAVETOURSEQ,
8 PRODRUNNR,
9 PRODRUNDATE,
10 PRODRUNID,
11 PRODRUNFINAL
12 )
13 as
14 select value(PW),
15 extractValue(value(PW),'/PickWave/Nr'),
16 TO_NUMBER(EXTRACTVALUE(value(PW),'/PickWave/ProdLine')),
17 extractValue(value(PW),'/PickWave/Tour'),
18 TO_NUMBER(extractValue(value(PW),'/PickWave/TourSeq')),
19 PRODRUNNR,
20 PRODRUNDATE,
21 PRODRUNID,
22 PRODRUNFINAL
23 FROM PROD_RUN_VIEW, table(xmlsequence(extract(PRODRUNNODE,'/ProdRun/PickWave'))) PW
24 /
View created.
Elapsed: 00:00:00.09
SQL> create or replace view CUSTOMER_VIEW
2 (
3 CUSTOMERNODE,
4 CUST,
5 MOD,
6 TOD,
7 SEQ,
8 PICKWAVENR,
9 PICKWAVEPRODLINE,
10 PICKWAVETOUR,
11 PICKWAVETOURSEQ,
12 PRODRUNNR,
13 PRODRUNDATE,
14 PRODRUNFINAL,
15 PRODRUNID
16 )
17 as
18 select value(CUST),
19 EXTRACTVALUE(VALUE(CUST), '/Customer/Cust'),
20 EXTRACTVALUE(VALUE(CUST), '/Customer/Mod'),
21 EXTRACTVALUE(VALUE(CUST), '/Customer/Tod'),
22 TO_NUMBER(EXTRACTVALUE(VALUE(CUST), '/Customer/Seq')),
23 PICKWAVENR,
24 PICKWAVEPRODLINE,
25 PICKWAVETOUR,
26 PICKWAVETOURSEQ,
27 PRODRUNNR,
28 PRODRUNDATE,
29 PRODRUNFINAL,
30 PRODRUNID
31 from PICK_WAVE_VIEW, table(xmlsequence(extract(PICKWAVENODE,'/PickWave/Customer'))) CUST
32 /
View created.
Elapsed: 00:00:00.10
SQL>
SQL> create or replace view INVOICE_ORDER_VIEW
2 (
3 INVORDERNR,
4 ITEM,
5 QTY,
6 PRIORITY,
7 REORDERING,
8 HLORDER,
9 DELDATE,
10 CUST,
11 MOD,
12 TOD,
13 SEQ,
14 PICKWAVENR,
15 PICKWAVEPRODLINE,
16 PICKWAVETOUR,
17 PICKWAVETOURSEQ,
18 PRODRUNNR,
19 PRODRUNDATE,
20 PRODRUNFINAL,
21 PRODRUNID
22 )
23 as
24 SELECT EXTRACTVALUE(VALUE(INV), '/InvOrder/Nr'),
25 EXTRACTVALUE(VALUE(INV), '/InvOrder/Item'),
26 EXTRACTVALUE(VALUE(INV), '/InvOrder/Qty'),
27 EXTRACTVALUE(VALUE(INV), '/InvOrder/Priority'),
28 EXTRACTVALUE(VALUE(INV), '/InvOrder/Reordering'),
29 EXTRACTVALUE(VALUE(INV), '/InvOrder/HlOrder'),
30 TO_DATE(EXTRACTVALUE(VALUE(INV), '/InvOrder/DelDate'),'DDMMYYYY'),
31 CUST,
32 MOD,
33 TOD,
34 SEQ,
35 PICKWAVENR,
36 PICKWAVEPRODLINE,
37 PICKWAVETOUR,
38 PICKWAVETOURSEQ,
39 PRODRUNNR,
40 PRODRUNDATE,
41 PRODRUNFINAL,
42 PRODRUNID
43 FROM CUSTOMER_VIEW, table(xmlsequence(extract(CUSTOMERNODE,'Customer/InvOrder'))) INV
44 /
View created.
Elapsed: 00:00:00.13
SQL> select * from INVOICE_ORDER_VIEW
2 /
IIO0000461 100000036 20 1 0 CSO000743 15-NOV-05 100000013
FO DDU 6 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000463 100000045 20 1 0 CSO000743 15-NOV-05 100000013
FO DDU 6 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000473 100000036 20 1 0 CSO000746 15-NOV-05 100000143
FO DDU 7 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000475 100000045 20 1 0 CSO000746 15-NOV-05 100000143
FO DDU 7 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000469 100000036 20 1 0 CSO000745 15-NOV-05 100000140
FO DDU 3 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000471 100000045 20 1 0 CSO000745 15-NOV-05 100000140
FO DDU 3 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000489 100000036 20 0 0 CSO000751 15-NOV-05 100000148
FO DDU 10 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000491 100000045 20 1 0 CSO000751 15-NOV-05 100000148
FO DDU 10 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000481 100000036 20 0 0 CSO000748 15-NOV-05 100000146
FO DDU 9 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000483 100000045 20 1 0 CSO000748 15-NOV-05 100000146
FO DDU 9 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000485 100000036 20 0 0 CSO000750 15-NOV-05 100000147
FO DDU 4 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000487 100000045 20 1 0 CSO000750 15-NOV-05 100000147
FO DDU 4 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000457 100000036 20 1 0 CSO000742 15-NOV-05 100000006
FO DDU 5 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000459 100000045 20 1 0 CSO000742 15-NOV-05 100000006
FO DDU 5 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000477 100000036 20 1 0 CSO000747 15-NOV-05 100000145
FO DDU 8 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000479 100000045 20 1 0 CSO000747 15-NOV-05 100000145
FO DDU 8 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000465 100000036 20 1 0 CSO000744 15-NOV-05 100000114
FO DDU 2 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
IIO0000467 100000045 20 1 0 CSO000744 15-NOV-05 100000114
FO DDU 2 IPW0000017 1 00000043_078
1
5 15-NOV-05 1 10
18 rows selected.
Elapsed: 00:00:00.22
Execution Plan
Plan hash value: 1730223965
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 18 | 10278 | 877 (0)| 00:00:11 |
| 1 | NESTED LOOPS | | 18 | 10278 | 877 (0)| 00:00:11 |
| 2 | NESTED LOOPS | | 18 | 8424 | 841 (0)| 00:00:11 |
| 3 | MERGE JOIN CARTESIAN | | 18 | 4680 | 805 (0)| 00:00:10 |
| 4 | TABLE ACCESS FULL | XML_ORDERS | 1 | 67 | 3 (0)| 00:00:01 |
| 5 | BUFFER SORT | | 18 | 3474 | 802 (0)| 00:00:10 |
| 6 | INDEX FAST FULL SCAN| SYS_IOT_TOP_64187 | 18 | 3474 | 802 (0)| 00:00:10 |
|* 7 | INDEX UNIQUE SCAN | SYS_IOT_TOP_64185 | 1 | 208 | 2 (0)| 00:00:01 |
|* 8 | INDEX RANGE SCAN | SYS_C008783 | 1 | | 0 (0)| 00:00:01 |
|* 9 | INDEX UNIQUE SCAN | SYS_IOT_TOP_64183 | 1 | 103 | 2 (0)| 00:00:01 |
|* 10 | INDEX RANGE SCAN | SYS_C008785 | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
7 - access("NESTED_TABLE_ID"="CUSTOMER_TAB"."SYS_NC0000800009$")
8 - access("NESTED_TABLE_ID"="CUSTOMER_TAB"."SYS_NC0000800009$")
9 - access("NESTED_TABLE_ID"="PICKWAVE_TAB"."SYS_NC0000800009$")
filter("NESTED_TABLE_ID"="XML_ORDERS"."SYS_NC0001000011$")
10 - access("NESTED_TABLE_ID"="PICKWAVE_TAB"."SYS_NC0000800009$")
Note
- dynamic sampling used for this statement
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
C:\oracle\xdb\otn\347125>You were sequencing the ProdRun node, which is a mistake. Only nodes which occur multiple times should be sequenced... -
How can i change a xmltype column's xml schema?
i create a table that have a xmltype column.this column is schema-based.
my problem is ,
now i want to this column's schema will be redefined to a global schema?
[b]how can i change the column's schema which already have a schema?When a schema is registered a lot of additonal annotations are added to the XML schema by the schema registration process - Look at the version of the XML schema under /sys/schemas/... in the XML DB repository. This information is unqiue to that version of the XML schema and is used internally to manage instance level metadata.
When instance documents are stored in the DB a set of metadata is generated for each document so that we can make sure that we can maintain DOM Fidelity. This metadata is tied directly to the XML schema the document is associated and is only valid in the context of that XML Schema.
So when the schema is registered locally and instances are stored the generated metadata is only valid in the context of the local schema. If the same schema is now registered globally new values will be generated for the annotations applied to the global version of the XML schema. Consequently the metadata associated with a document belonging to the local version of the XML schema has no meaning when viewed in the context of the global version of the XML schema.
The net effect of this is that you will need to copy the data in order to get documents where the metadata for each document is based on the global version of the XML SChema. -
How to create a Context index on a Substitutable Column ?
Hi all,
I have a type t1 and a subtype t2 which defines a new
sys.XMLType column d and a table t_tab of t1.
If I issue the following :
create index t_idx on t_tab t(treat(value(t) as t2).d) indextype
is ctxsys.context;
I get the following message:
ERROR at line 1:
ORA-29855: error occurred in the execution of ODCIINDEXCREATE
routine
ORA-20000: Oracle Text error:
DRG-50857: oracle error in drsxsopen
ORA-00904: invalid column name
ORA-06512: at "CTXSYS.DRUE", line 157
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 176
Any suggestion ?
Thanks
AlexAlex,
Please file an iTAR report at http://metalink.oracle.com. This
could be a known bug.
Regards,
Geoff
Hi all,
I have a type t1 and a subtype t2 which defines a new
sys.XMLType column d and a table t_tab of t1.
If I issue the following :
create index t_idx on t_tab t(treat(value(t) as t2).d) indextype
is ctxsys.context;
I get the following message:
ERROR at line 1:
ORA-29855: error occurred in the execution of ODCIINDEXCREATE
routine
ORA-20000: Oracle Text error:
DRG-50857: oracle error in drsxsopen
ORA-00904: invalid column name
ORA-06512: at "CTXSYS.DRUE", line 157
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 176
Any suggestion ?
Thanks
Alex -
How to create index on XMLType column extension?
I have an XMLType column named "info" whose corresponding global element has a complexType "InfoType" in namespace "http://example.org/ord". The "InfoType" complexType is extended in two namespaces, "http://example.org/info/zipcode" and "http://example.org/info/street". How do I create a unique index using an "InfoType" element contributed from one of the extension namespaces?
I have included below a SQL script that completely describes the problem.
Thanks in advance for your assistance?
- Ron
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'chapter04prod.xsd',
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://example.org/prod"
targetNamespace="http://example.org/prod"
elementFormDefault="unqualified">
<xsd:complexType name="ItemsType">
<xsd:sequence>
<xsd:element name="product" type="ProductType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ProductType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="size" type="SizeType"/>
<xsd:element name="color" type="ColorType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SizeType">
<xsd:simpleContent>
<xsd:extension base="xsd:integer">
<xsd:attribute name="system" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="ColorType">
<xsd:attribute name="value" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>',
TRUE,
TRUE,
FALSE,
FALSE);
END;
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'chapter04ord1.xsd',
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.org/ord"
xmlns="http://example.org/ord"
xmlns:prod="http://example.org/prod"
elementFormDefault="qualified">
<xsd:import namespace="http://example.org/prod"
schemaLocation="chapter04prod.xsd"/>
<xsd:simpleType name="OrderNumType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:complexType name="InfoType"/>
<xsd:complexType name="CustomerType">
<xsd:all>
<xsd:element name="name" type="CustNameType"/>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="info" type="InfoType" form="unqualified"/>
</xsd:all>
</xsd:complexType>
<xsd:simpleType name="CustNameType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:element name="order" type="OrderType"/>
<xsd:element name="customer" type="CustomerType"/>
<xsd:complexType name="OrderType">
<xsd:sequence>
<xsd:element name="number" type="OrderNumType"/>
<xsd:element name="customer" type="CustomerType"
maxOccurs="unbounded"/>
<xsd:element name="items" type="prod:ItemsType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>',
TRUE,
TRUE,
FALSE,
FALSE);
END;
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'chapter04infozipcode.xsd',
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ord="http://example.org/ord"
xmlns="http://example.org/info/zipcode"
targetNamespace="http://example.org/info/zipcode"
elementFormDefault="unqualified">
<xsd:import namespace="http://example.org/ord"
schemaLocation="chapter04ord1.xsd"/>
<xsd:complexType name="InfoType">
<xsd:complexContent>
<xsd:extension base="ord:InfoType">
<xsd:sequence>
<xsd:element name="zipcode" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>',
TRUE,
TRUE,
FALSE,
FALSE);
END;
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'chapter04infostreet.xsd',
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ord="http://example.org/ord"
xmlns="http://example.org/info/street"
targetNamespace="http://example.org/info/street"
elementFormDefault="unqualified">
<xsd:import namespace="http://example.org/ord"
schemaLocation="chapter04ord1.xsd"/>
<xsd:complexType name="InfoType">
<xsd:complexContent>
<xsd:extension base="ord:InfoType">
<xsd:sequence>
<xsd:element name="street" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>',
TRUE,
TRUE,
FALSE,
FALSE);
END;
BEGIN
DBMS_XMLSCHEMA.registerSchema(
'chapter04nonamespace.xsd',
'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ord="http://example.org/ord">
<xsd:import namespace="http://example.org/ord"
schemaLocation="chapter04ord1.xsd"/>
<xsd:element name="info" type="ord:InfoType">
</xsd:schema>',
TRUE,
TRUE,
FALSE,
FALSE);
END;
CREATE TABLE customer (
name VARCHAR(64),
number INTEGER,
info XMLTYPE)
XMLType info STORE AS OBJECT RELATIONAL
XMLSCHEMA "chapter04nonamespace.xsd"
ELEMENT "info";
INSERT INTO customer (name, number, info)
VALUES ('George Jones', 1,
XMLType(
'<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:street="http://example.org/info/zipcode"
xsi:type="zipcode:InfoType">
<zipcode>28877</zipcode>
</info>');
INSERT INTO customer (name, number, info)
VALUES ('Jim Jones', 2,
XMLType(
'<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:street="http://example.org/info/street"
xsi:type="street:InfoType">
<street>3456 Autumn Lane</street>
</info>');
SELECT name,
extractValue(info, '/info/street')
FROM customer
WHERE extractValue(info, '/info/street/text()') LIKE '3456%';
-- How does one create a unique index as follows?
CREATE UNIQUE INDEX customer_infostreet ON customer (??????);
-- The following insert should fail with unique index violation!
INSERT INTO customer (name, number, info)
VALUES ('Jerry Jones', 3,
XMLType(
'<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:street="http://example.org/info/street"
xsi:type="street:InfoType">
<street>3456 Autumn Lane</street>
</info>');Ron
Glad you found a solution.. However a more efficient solution is show below
SQL> connect sys/ as sysdba
Enter password:
Connected.
SQL> set define on
SQL> --
SQL> define USERNAME = OTNTEST
SQL> --
SQL> def PASSWORD = OTNTEST
SQL> --
SQL> def USER_TABLESPACE = USERS
SQL> --
SQL> def TEMP_TABLESPACE = TEMP
SQL> --
SQL> drop user &USERNAME cascade
2 /
old 1: drop user &USERNAME cascade
new 1: drop user OTNTEST cascade
User dropped.
SQL> grant connect, resource to &USERNAME identified by &PASSWORD
2 /
old 1: grant connect, resource to &USERNAME identified by &PASSWORD
new 1: grant connect, resource to OTNTEST identified by OTNTEST
Grant succeeded.
SQL> grant create any directory, drop any directory to &USERNAME
2 /
old 1: grant create any directory, drop any directory to &USERNAME
new 1: grant create any directory, drop any directory to OTNTEST
Grant succeeded.
SQL> grant alter session, create view to &USERNAME
2 /
old 1: grant alter session, create view to &USERNAME
new 1: grant alter session, create view to OTNTEST
Grant succeeded.
SQL> alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
2 /
old 1: alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
new 1: alter user OTNTEST default tablespace USERS temporary tablespace TEMP
User altered.
SQL> connect &USERNAME/&PASSWORD
Connected.
SQL> --
SQL> alter session set events ='19027 trace name context forever, level 0x800'
2 /
Session altered.
SQL> BEGIN
2 DBMS_XMLSCHEMA.registerSchema(
3 'chapter04prod.xsd',
4 '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/prod" targetNamespa
fault="unqualified">
5 <xsd:complexType name="ItemsType">
6 <xsd:sequence>
7 <xsd:element name="product" type="ProductType"/>
8 </xsd:sequence>
9 </xsd:complexType>
10 <xsd:complexType name="ProductType">
11 <xsd:sequence>
12 <xsd:element name="num" type="xsd:integer"/>
13 <xsd:element name="name" type="xsd:string"/>
14 <xsd:element name="size" type="SizeType"/>
15 <xsd:element name="color" type="ColorType"/>
16 </xsd:sequence>
17 </xsd:complexType>
18 <xsd:complexType name="SizeType">
19 <xsd:simpleContent>
20 <xsd:extension base="xsd:integer">
21 <xsd:attribute name="system" type="xsd:string"/>
22 </xsd:extension>
23 </xsd:simpleContent>
24 </xsd:complexType>
25 <xsd:complexType name="ColorType">
26 <xsd:attribute name="value" type="xsd:string"/>
27 </xsd:complexType>
28 </xsd:schema>',
29 TRUE, TRUE, FALSE, FALSE);
30 END;
31 /
PL/SQL procedure successfully completed.
SQL> BEGIN
2 DBMS_XMLSCHEMA.registerSchema(
3 'chapter04ord1.xsd',
4 '<xsd:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns
://example.org/prod" targetNamespace="http://example.org/ord" elementFormDefault="qualified">
5 <xsd:import namespace="http://example.org/prod" schemaLocation="chapter04prod.xsd"/>
6 <xsd:simpleType name="OrderNumType">
7 <xsd:restriction base="xsd:string"/>
8 </xsd:simpleType>
9 <xsd:complexType name="InfoType" xdb:SQLType="INFO_TYPE_T"/>
10 <xsd:complexType name="CustomerType">
11 <xsd:all>
12 <xsd:element name="name" type="CustNameType"/>
13 <xsd:element name="num" type="xsd:integer"/>
14 <xsd:element name="info" type="InfoType" minOccurs="1" form="unqualified"/>
15 </xsd:all>
16 </xsd:complexType>
17 <xsd:simpleType name="CustNameType">
18 <xsd:restriction base="xsd:string"/>
19 </xsd:simpleType>
20 <xsd:element name="customers" type="CustomersType"/>
21 <xsd:complexType name="CustomersType">
22 <xsd:sequence>
23 <xsd:element name="customer" type="CustomerType" minOccurs="0" maxOccurs="unbounded"
24 </xsd:sequence>
25 </xsd:complexType>
26 <xsd:element name="order" type="OrderType"/>
27 <xsd:element name="customer" type="CustomerType"/>
28 <xsd:complexType name="OrderType">
29 <xsd:sequence>
30 <xsd:element name="num" type="OrderNumType"/>
31 <xsd:element name="customer" type="CustomerType" maxOccurs="unbounded"/>
32 <xsd:element name="items" type="prod:ItemsType"/>
33 </xsd:sequence>
34 </xsd:complexType>
35 </xsd:schema>',
36 TRUE, TRUE, FALSE, FALSE);
37 END;
38 /
PL/SQL procedure successfully completed.
SQL> BEGIN
2 DBMS_XMLSCHEMA.registerSchema(
3 'chapter04infozipcode.xsd',
4 '<xsd:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns
//example.org/info/zipcode" targetNamespace="http://example.org/info/zipcode" elementFormDefault="unqualifie
5 <xsd:import namespace="http://example.org/ord" schemaLocation="chapter04ord1.xsd"/>
6 <xsd:complexType name="InfoType" xdb:SQLType="ZIPCODE_INFO_TYPE_T">
7 <xsd:complexContent>
8 <xsd:extension base="ord:InfoType">
9 <xsd:sequence>
10 <xsd:element name="zipcode" type="xsd:string"/>
11 <xsd:element name="suffix" type="xsd:string"/>
12 </xsd:sequence>
13 </xsd:extension>
14 </xsd:complexContent>
15 </xsd:complexType>
16 </xsd:schema>',
17 TRUE, TRUE, FALSE, FALSE);
18 END;
19 /
PL/SQL procedure successfully completed.
SQL>
SQL> BEGIN
2 DBMS_XMLSCHEMA.registerSchema(
3 'chapter04infostreet.xsd',
4 '<xsd:schema xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns
//example.org/info/street" targetNamespace="http://example.org/info/street" elementFormDefault="unqualified"
5 <xsd:import namespace="http://example.org/ord" schemaLocation="chapter04ord1.xsd"/>
6 <xsd:complexType name="InfoType" xdb:SQLType="STREET_INFO_TYPE_T">
7 <xsd:complexContent>
8 <xsd:extension base="ord:InfoType">
9 <xsd:sequence>
10 <xsd:element name="street" type="xsd:string"/>
11 <xsd:element name="suffix" type="xsd:string"/>
12 </xsd:sequence>
13 </xsd:extension>
14 </xsd:complexContent>
15 </xsd:complexType>
16 </xsd:schema>',
17 TRUE, TRUE, FALSE, FALSE);
18 END;
19 /
PL/SQL procedure successfully completed.
SQL>
SQL> BEGIN
2 DBMS_XMLSCHEMA.registerSchema(
3 'chapter04nonamespace.xsd',
4 '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ord="http://example.org/ord">
5 <xsd:import namespace="http://example.org/ord" schemaLocation="chapter04ord1.xsd"/>
6 <xsd:element name="info" type="ord:InfoType"/>
7 </xsd:schema>',
8 TRUE, TRUE, FALSE, FALSE);
9 END;
10 /
PL/SQL procedure successfully completed.
SQL>
SQL> CREATE TABLE customer (
2 name VARCHAR(64),
3 num INTEGER,
4 info XMLTYPE)
5 XMLType info STORE AS OBJECT RELATIONAL
6 XMLSCHEMA "chapter04nonamespace.xsd"
7 ELEMENT "info";
Table created.
SQL>
SQL> INSERT INTO customer (name, num, info)
2 VALUES ('George Jones', 1,
3 XMLType(
4 '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:zipcode="http://example.org/info/zip
5 <zipcode>28877</zipcode>
6 <suffix>s1</suffix>
7 </info>'));
1 row created.
SQL>
SQL> INSERT INTO customer (name, num, info)
2 VALUES ('Jim Jones', 2,
3 XMLType(
4 '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:street="http://example.org/info/stre
5 <street>3456 Autumn Lane</street>
6 <suffix>s2</suffix>
7 </info>'));
1 row created.
SQL> /
1 row created.
SQL> SELECT name,
2 extractValue(info, '/info/zipcode'),
3 extractValue(info, '/info/street')
4 FROM customer
5 WHERE extractValue(info, '/info/zipcode/text()') LIKE '2%'
6 OR extractValue(info, '/info/street/text()') LIKE '3456%';
NAME
EXTRACTVALUE(INFO,'/INFO/ZIPCODE')
EXTRACTVALUE(INFO,'/INFO/STREET')
George Jones
28877
Jim Jones
3456 Autumn Lane
NAME
EXTRACTVALUE(INFO,'/INFO/ZIPCODE')
EXTRACTVALUE(INFO,'/INFO/STREET')
Jim Jones
3456 Autumn Lane
SQL>
SQL> CREATE UNIQUE INDEX customer_infozipcode ON customer(
2 extractValue
3 (
4 info,
5 '/info[@xsi:type="zipcode:InfoType"]/zipcode',
6 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7 xmlns:zipcode="http://example.org/info/zipcode"'
8 ))
9 /
Index created.
SQL> select column_name
2 from user_ind_columns
3 where INDEX_NAME = 'CUSTOMER_INFOZIPCODE'
4 /
COLUMN_NAME
SYS_NC00014$
SQL> select INDEX_NAME,COLUMN_EXPRESSION
2 from user_ind_expressions
3 /
INDEX_NAME
COLUMN_EXPRESSION
CUSTOMER_INFOZIPCODE
EXTRACTVALUE(SYS_MAKEXML('0341F05603124922B4F6F94DC5E30C2F',4870,"SYS_NC00004$",
SQL> DROP INDEX CUSTOMER_INFOZIPCODE
2 /
Index dropped.
SQL> desc INFO_TYPE_T
INFO_TYPE_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
SQL> --
SQL> desc ZIPCODE_INFO_TYPE_T
ZIPCODE_INFO_TYPE_T extends OTNTEST.INFO_TYPE_T
ZIPCODE_INFO_TYPE_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
zipcode VARCHAR2(4000 CHAR)
suffix VARCHAR2(4000 CHAR)
SQL> --
SQL> desc STREET_INFO_TYPE_T
STREET_INFO_TYPE_T extends OTNTEST.INFO_TYPE_T
STREET_INFO_TYPE_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
street VARCHAR2(4000 CHAR)
suffix VARCHAR2(4000 CHAR)
SQL> --
SQL> CREATE UNIQUE INDEX customer_infozipcode ON customer(TREAT(INFO.XMLDATA AS ZIPCODE_INFO_TYPE_T)."zipcod
2 /
Index created.
SQL> select column_name
2 from user_ind_columns
3 where INDEX_NAME = 'CUSTOMER_INFOZIPCODE'
4 /
COLUMN_NAME
TREAT("SYS_NC00007$" AS "ZIPCODE_INFO_TYPE_T")."zipcode"
SQL> select INDEX_NAME,COLUMN_EXPRESSION
2 from user_ind_expressions
3 /
no rows selected
SQL> INSERT INTO customer (name, num, info)
2 VALUES ('Jerry Jones', 3,
3 XMLType(
4 '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:zipcode="http://example.org/info/zip
5 <zipcode>28877</zipcode>
6 <suffix>s1</suffix>
7 </info>'))
8 /
INSERT INTO customer (name, num, info)
ERROR at line 1:
ORA-00001: unique constraint (OTNTEST.CUSTOMER_INFOZIPCODE) violated
SQL> INSERT INTO customer (name, num, info)
2 VALUES ('Jerry Jones', 3,
3 XMLType(
4 '<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:street="http://example.org/info/stre
5 <street>3456 Autumn Lane</street>
6 <suffix>s3</suffix>
7 </info>'))
8 /
1 row created.
SQL>In you solution a functional index was created. In my case, by breaking the XML abstraction, and using object-relational SQL to create the index (DDL statements are the one case where I feel this is acceptable) I was able to create a pure B-TREE index which has the same effect.. -
Insert performance on a table with schema based XMLType column
Hi,
We are inserting around 500K rows into a table which has one XMLType column (schema based). Schema is simple and the size of the XMLType column is also not very large (on an average only around 100 bytes (max might be around 1k-2k), but it takes around 1 hr for every 20K rows, which seems very slow.
The schema is like this :
<schema targetNamespace="http://www.citadon.com/xml/test.xsd"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb"
xdb:storeVarrayAsTable="true"
version="1.0" elementFormDefault="qualified">
<element name="cas">
<complexType>
<sequence>
<element name="ca" minOccurs="0" maxOccurs="unbounded">
<complexType>
<sequence>
<element name="id" type="string"/>
<element name="value" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
Any thoughts on how to improve performance?
-SriniYou need to have sufficient data.. Also the event show in the following code may help depending on the nature of the query....
Note in the PurchaseOrder Example if I only have 133 docs, instead of 10,000 I will get tablescan and index full scans
C:\oracle\xdb\bugs\xdbBasicDemo>sqlplus /nolog @testcase XDBTEST XDBTEST
SQL*Plus: Release 10.1.0.3.0 - Production on Fri Aug 27 22:57:36 2004
Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> spool testcase.log
SQL> set trimspool on
SQL> connect &1/&2
Connected.
SQL> --
SQL> set timing on
SQL> set long 10000
SQL> set pages 10000
SQL> set feedback on
SQL> set lines 132
SQL> set pages 50
SQL> --
SQL> drop index iPartNumberIndex
2 /
Index dropped.
Elapsed: 00:00:02.25
SQL> alter index LINEITEM_LIST rebuild
2 /
Index altered.
Elapsed: 00:00:02.15
SQL> desc PURCHASEORDER
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "http://localhost:8080/home/SCOTT/poSource/xsd/purchaseOrder.xsd" Element "Pu
ject-relational TYPE "PURCHASEORDER_T"
SQL> --
SQL> col level format 99999
SQL> col parent_table_column format A32
SQL> col table_name format A32
SQL> col table_type_name format A32
SQL> --
SQL> select level, PARENT_TABLE_COLUMN, TABLE_TYPE_NAME, TABLE_NAME
2 from USER_NESTED_TABLES
3 connect by PRIOR TABLE_NAME = PARENT_TABLE_NAME
4 start with PARENT_TABLE_NAME = 'PURCHASEORDER'
5 /
LEVEL PARENT_TABLE_COLUMN TABLE_TYPE_NAME TABLE_NAME
1 "XMLDATA"."ACTIONS"."ACTION" ACTION_V ACTION_TABLE
1 "XMLDATA"."LINEITEMS"."LINEITEM" LINEITEM_V LINEITEM_TABLE
2 rows selected.
Elapsed: 00:00:13.60
SQL> desc LINEITEM_T
LINEITEM_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
ITEMNUMBER NUMBER(38)
DESCRIPTION VARCHAR2(256 CHAR)
PART PART_T
SQL> --
SQL> desc PART_T
PART_T is NOT FINAL
Name Null? Type
SYS_XDBPD$ XDB.XDB$RAW_LIST_T
PART_NUMBER VARCHAR2(14 CHAR)
QUANTITY NUMBER(12,2)
UNITPRICE NUMBER(8,4)
SQL> --
SQL> select count(*)
2 from purchaseorder
3 /
COUNT(*)
10000
1 row selected.
Elapsed: 00:00:05.31
SQL> select count(*)
2 from purchaseorder,
3 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
4 /
COUNT(*)
148814
1 row selected.
Elapsed: 00:09:40.54
SQL> create index iPartNumberIndex
2 on LINEITEM_TABLE l
3 ( l.PART.PART_NUMBER,NESTED_TABLE_ID)
4 /
Index created.
Elapsed: 00:00:36.11
SQL> explain plan for
2 select count(*)
3 from purchaseorder
4 where existsNode(object_value,'/PurchaseOrder/LineItems/LineItem[Part/@Id="717951002372"]') = 1
5 /
Explained.
Elapsed: 00:00:01.14
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 2571550067
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 116 | 93 (2)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | 116 | | |
| 2 | NESTED LOOPS | | 25 | 2900 | 93 (2)| 00:00:02 |
| 3 | SORT UNIQUE | | 25 | 1675 | 79 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | LINEITEM_DATA | 25 | 1675 | 79 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | | 3 (0)| 00:00:01 |
|* 6 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 49 | 1 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - access("SYS_NC00011$"='717951002372')
5 - access("SYS_NC00011$"='717951002372')
6 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in
stance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-propert
ies/><read-contents/></privilege>''))=1)
7 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
26 rows selected.
Elapsed: 00:00:03.12
SQL> select count(*)
2 from purchaseorder
3 where existsNode(object_value,'/PurchaseOrder/LineItems/LineItem[Part/@Id="717951002372"]') = 1
4 /
COUNT(*)
33
1 row selected.
Elapsed: 00:00:04.63
SQL> select count(*)
2 from purchaseorder,
3 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
4 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
5 /
COUNT(*)
33
1 row selected.
Elapsed: 00:00:00.32
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 2571550067
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 116 | 93 (2)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | 116 | | |
| 2 | NESTED LOOPS | | 25 | 2900 | 93 (2)| 00:00:02 |
| 3 | SORT UNIQUE | | 25 | 1675 | 79 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | LINEITEM_DATA | 25 | 1675 | 79 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | | 3 (0)| 00:00:01 |
|* 6 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 49 | 1 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - access("SYS_NC00011$"='717951002372')
5 - access("SYS_NC00011$"='717951002372')
6 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in
stance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-propert
ies/><read-contents/></privilege>''))=1)
7 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
26 rows selected.
Elapsed: 00:00:00.04
SQL> explain plan for
2 select extractValue(object_value,'/PurchaseOrder/Reference')
3 from purchaseorder,
4 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
5 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
6 /
Explained.
Elapsed: 00:00:00.07
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 713363872
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 25 | 8000 | 104 (0)| 00:00:02 |
| 1 | NESTED LOOPS | | 25 | 8000 | 104 (0)| 00:00:02 |
|* 2 | INDEX UNIQUE SCAN | LINEITEM_DATA | 25 | 1675 | 79 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | | 3 (0)| 00:00:01 |
|* 4 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 253 | 1 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("SYS_NC00011$"='717951002372')
3 - access("SYS_NC00011$"='717951002372')
4 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-i
nstance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-proper
ties/><read-contents/></privilege>''))=1)
5 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
24 rows selected.
Elapsed: 00:00:00.04
SQL> select extractValue(object_value,'/PurchaseOrder/Reference')
2 from purchaseorder,
3 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
4 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
5 /
EXTRACTVALUE(OBJECT_VALUE,'/PU
MWEISS-20030616154327385GMT
NSARCHAN-20030703170041824GMT
HBAER-20030206173836987GMT
LOZER-20031110131149107GMT
WTAYLOR-20030120174534374GMT
MHARTSTE-20031103172937613GMT
KGEE-20030919215826550GMT
PSULLY-20030712141634504GMT
JPATEL-20030630175356693GMT
RMATOS-2003072920455000GMT
DRAPHEAL-20030528180033254GMT
JRUSSEL-20031121213026539GMT
PTUCKER-20030918160532301GMT
SVOLLMAN-20031027120838903GMT
WGIETZ-20030208185026303GMT
TFOX-20030110164614994GMT
JPATEL-20030304214301386GMT
GGEONI-20030606135257846GMT
STOBIAS-20030817120358785GMT
COLSEN-20030525200717658GMT
SBAIDA-20030224182546606GMT
IMIKKILI-20030118180347537GMT
ABULL-20030429162730766GMT
NSARCHAN-20031113183134873GMT
LBISSOT-20030809134114505GMT
JKING-20030420162058859GMT
JMALLIN-20030506152048261GMT
AFRIPP-20030311153808601GMT
SHIGGINS-20030831151756257GMT
DBERNSTE-20030626122725631GMT
KPARTNER-20031021160248962GMT
ABANDA-2003062721524842GMT
DOCONNEL-20030904214708637GMT
33 rows selected.
Elapsed: 00:00:00.07
SQL> explain plan for
2 select extractValue(object_value,'/PurchaseOrder/Reference')
3 from purchaseorder
4 where existsNode
5 (
6 object_value,
7 '/PurchaseOrder/LineItems/LineItem/Part[@Id="717951002372"]'
8 ) = 1
9 /
Explained.
Elapsed: 00:00:00.02
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 849879259
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 25 | 8000 | 93 (2)| 00:00:02 |
| 1 | NESTED LOOPS | | 25 | 8000 | 93 (2)| 00:00:02 |
| 2 | SORT UNIQUE | | 25 | 1675 | 79 (0)| 00:00:01 |
|* 3 | INDEX UNIQUE SCAN | LINEITEM_DATA | 25 | 1675 | 79 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | | 3 (0)| 00:00:01 |
|* 5 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 253 | 1 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - access("SYS_NC00011$"='717951002372')
4 - access("SYS_NC00011$"='717951002372')
5 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-i
nstance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-proper
ties/><read-contents/></privilege>''))=1)
6 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
25 rows selected.
Elapsed: 00:00:00.03
SQL> select extractValue(object_value,'/PurchaseOrder/Reference')
2 from purchaseorder
3 where existsNode
4 (
5 object_value,
6 '/PurchaseOrder/LineItems/LineItem/Part[@Id="717951002372"]'
7 ) = 1
8 /
EXTRACTVALUE(OBJECT_VALUE,'/PU
MWEISS-20030616154327385GMT
NSARCHAN-20030703170041824GMT
HBAER-20030206173836987GMT
LOZER-20031110131149107GMT
WTAYLOR-20030120174534374GMT
MHARTSTE-20031103172937613GMT
KGEE-20030919215826550GMT
PSULLY-20030712141634504GMT
JPATEL-20030630175356693GMT
RMATOS-2003072920455000GMT
DRAPHEAL-20030528180033254GMT
JRUSSEL-20031121213026539GMT
PTUCKER-20030918160532301GMT
SVOLLMAN-20031027120838903GMT
WGIETZ-20030208185026303GMT
TFOX-20030110164614994GMT
JPATEL-20030304214301386GMT
GGEONI-20030606135257846GMT
STOBIAS-20030817120358785GMT
COLSEN-20030525200717658GMT
SBAIDA-20030224182546606GMT
IMIKKILI-20030118180347537GMT
ABULL-20030429162730766GMT
NSARCHAN-20031113183134873GMT
LBISSOT-20030809134114505GMT
JKING-20030420162058859GMT
JMALLIN-20030506152048261GMT
AFRIPP-20030311153808601GMT
SHIGGINS-20030831151756257GMT
DBERNSTE-20030626122725631GMT
KPARTNER-20031021160248962GMT
ABANDA-2003062721524842GMT
DOCONNEL-20030904214708637GMT
33 rows selected.
Elapsed: 00:00:00.04
SQL> alter session set events ='19027 trace name context forever, level 0x800000'
2 /
Session altered.
Elapsed: 00:00:00.00
SQL> explain plan for
2 select count(*)
3 from purchaseorder
4 where existsNode(object_value,'/PurchaseOrder/LineItems/LineItem[Part/@Id="717951002372"]') = 1
5 /
Explained.
Elapsed: 00:00:00.03
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 3049344732
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 69 | 17 (6)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 69 | | |
| 2 | NESTED LOOPS | | 25 | 1725 | 17 (6)| 00:00:01 |
| 3 | SORT UNIQUE | | 25 | 750 | 3 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | 750 | 3 (0)| 00:00:01 |
|* 5 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 39 | 1 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - access("SYS_NC00011$"='717951002372')
5 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in
stance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-propert
ies/><read-contents/></privilege>''))=1)
6 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
24 rows selected.
Elapsed: 00:00:00.03
SQL> select count(*)
2 from purchaseorder
3 where existsNode(object_value,'/PurchaseOrder/LineItems/LineItem[Part/@Id="717951002372"]') = 1
4 /
COUNT(*)
33
1 row selected.
Elapsed: 00:00:00.01
SQL> select count(*)
2 from purchaseorder,
3 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
4 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
5 /
COUNT(*)
33
1 row selected.
Elapsed: 00:00:00.01
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 3049344732
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 69 | 17 (6)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 69 | | |
| 2 | NESTED LOOPS | | 25 | 1725 | 17 (6)| 00:00:01 |
| 3 | SORT UNIQUE | | 25 | 750 | 3 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | 750 | 3 (0)| 00:00:01 |
|* 5 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 39 | 1 (0)| 00:00:01 |
|* 6 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - access("SYS_NC00011$"='717951002372')
5 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-in
stance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-propert
ies/><read-contents/></privilege>''))=1)
6 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
24 rows selected.
Elapsed: 00:00:00.03
SQL> explain plan for
2 select extractValue(object_value,'/PurchaseOrder/Reference')
3 from purchaseorder,
4 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
5 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
6 /
Explained.
Elapsed: 00:00:00.06
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 1516269755
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 25 | 2450 | 28 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 25 | 2450 | 28 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | 750 | 3 (0)| 00:00:01 |
|* 3 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 68 | 1 (0)| 00:00:01 |
|* 4 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("SYS_NC00011$"='717951002372')
3 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-i
nstance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-proper
ties/><read-contents/></privilege>''))=1)
4 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
22 rows selected.
Elapsed: 00:00:00.04
SQL> select extractValue(object_value,'/PurchaseOrder/Reference')
2 from purchaseorder,
3 table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l
4 where existsNode(value(l),'/LineItem[Part/@Id="717951002372"]') = 1
5 /
EXTRACTVALUE(OBJECT_VALUE,'/PU
MWEISS-20030616154327385GMT
NSARCHAN-20030703170041824GMT
HBAER-20030206173836987GMT
LOZER-20031110131149107GMT
WTAYLOR-20030120174534374GMT
MHARTSTE-20031103172937613GMT
KGEE-20030919215826550GMT
PSULLY-20030712141634504GMT
JPATEL-20030630175356693GMT
RMATOS-2003072920455000GMT
DRAPHEAL-20030528180033254GMT
JRUSSEL-20031121213026539GMT
PTUCKER-20030918160532301GMT
SVOLLMAN-20031027120838903GMT
WGIETZ-20030208185026303GMT
TFOX-20030110164614994GMT
JPATEL-20030304214301386GMT
GGEONI-20030606135257846GMT
STOBIAS-20030817120358785GMT
COLSEN-20030525200717658GMT
SBAIDA-20030224182546606GMT
IMIKKILI-20030118180347537GMT
ABULL-20030429162730766GMT
NSARCHAN-20031113183134873GMT
LBISSOT-20030809134114505GMT
JKING-20030420162058859GMT
JMALLIN-20030506152048261GMT
AFRIPP-20030311153808601GMT
SHIGGINS-20030831151756257GMT
DBERNSTE-20030626122725631GMT
KPARTNER-20031021160248962GMT
ABANDA-2003062721524842GMT
DOCONNEL-20030904214708637GMT
33 rows selected.
Elapsed: 00:00:00.01
SQL> explain plan for
2 select extractValue(object_value,'/PurchaseOrder/Reference')
3 from purchaseorder
4 where existsNode
5 (
6 object_value,
7 '/PurchaseOrder/LineItems/LineItem/Part[@Id="717951002372"]'
8 ) = 1
9 /
Explained.
Elapsed: 00:00:00.03
SQL> select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'))
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 1197255270
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 25 | 2450 | 17 (6)| 00:00:01 |
| 1 | NESTED LOOPS | | 25 | 2450 | 17 (6)| 00:00:01 |
| 2 | SORT UNIQUE | | 25 | 750 | 3 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | IPARTNUMBERINDEX | 25 | 750 | 3 (0)| 00:00:01 |
|* 4 | TABLE ACCESS BY INDEX ROWID| PURCHASEORDER | 1 | 68 | 1 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | LINEITEM_LIST | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - access("SYS_NC00011$"='717951002372')
4 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype(''<privilege
xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-i
nstance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-proper
ties/><read-contents/></privilege>''))=1)
5 - access("NESTED_TABLE_ID"="PURCHASEORDER"."SYS_NC0003400035$")
23 rows selected.
Elapsed: 00:00:00.03
SQL> select extractValue(object_value,'/PurchaseOrder/Reference')
2 from purchaseorder
3 where existsNode
4 (
5 object_value,
6 '/PurchaseOrder/LineItems/LineItem/Part[@Id="717951002372"]'
7 ) = 1
8 /
EXTRACTVALUE(OBJECT_VALUE,'/PU
MWEISS-20030616154327385GMT
NSARCHAN-20030703170041824GMT
HBAER-20030206173836987GMT
LOZER-20031110131149107GMT
WTAYLOR-20030120174534374GMT
MHARTSTE-20031103172937613GMT
KGEE-20030919215826550GMT
PSULLY-20030712141634504GMT
JPATEL-20030630175356693GMT
RMATOS-2003072920455000GMT
DRAPHEAL-20030528180033254GMT
JRUSSEL-20031121213026539GMT
PTUCKER-20030918160532301GMT
SVOLLMAN-20031027120838903GMT
WGIETZ-20030208185026303GMT
TFOX-20030110164614994GMT
JPATEL-20030304214301386GMT
GGEONI-20030606135257846GMT
STOBIAS-20030817120358785GMT
COLSEN-20030525200717658GMT
SBAIDA-20030224182546606GMT
IMIKKILI-20030118180347537GMT
ABULL-20030429162730766GMT
NSARCHAN-20031113183134873GMT
LBISSOT-20030809134114505GMT
JKING-20030420162058859GMT
JMALLIN-20030506152048261GMT
AFRIPP-20030311153808601GMT
SHIGGINS-20030831151756257GMT
DBERNSTE-20030626122725631GMT
KPARTNER-20031021160248962GMT
ABANDA-2003062721524842GMT
DOCONNEL-20030904214708637GMT
33 rows selected.
Elapsed: 00:00:00.03
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options -
Creating Indexes within an XMLType column
Hi,
I have following XML document stored as XMLType column,
<ocaStatus xmlns="http://xmlbeans.apache.org/ocastatus"><status><statusCode>934</statusCode><statusDate>Wed Apr 07 16:05:53 GMT+05:30 2010</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>934</statusCode><statusDate>Wed Apr 07 15:58:25 GMT+05:30 2010</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>934</statusCode><statusDate>Wed Apr 07 15:54:02 GMT+05:30 2010</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>750</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Document Metadata is correct.</comment></status><status><statusCode>934</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Sent to LTC</comment></status><status><statusCode>932</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Loaded to Novus</comment></status><status><statusCode>700</statusCode><statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate><userId>u0121845</userId><comment>Document is deleted from OCA.</comment></status></ocaStatus>
I created following Indexes within the XML,
CREATE INDEX "OCA_DEV"."OCA_STATUS_CODE_INDEX" ON "OCA_DEV"."DOCUMENT_STATUS_XML" (EXTRACTVALUE('/ocaStatus/status/statusCode'));
CREATE INDEX "OCA_DEV"."OCA_STATUS_DATE_INDEX" ON "OCA_DEV"."DOCUMENT_STATUS_XML" (EXTRACTVALUE('/ocaStatus/status/statusDate'));
However the problem is that I will be having multiple status within each XML which violates the Indexing.
Is there any way I can still create the Indexes allowing multiple status values in each XML?
Thanks in advance.Hi,
You may want to store your document as a schema-based, object-relational XMLType to achieve that.
Then you'll be able to create indexes on the nested table used to store each "status" element.
Here's an example based on your sample document.
1) First, create and register a schema. The following is basic but sufficient here, let's call it "ocastatus.xsd" :
<?xml version="1.0"?>
<xsd:schema
targetNamespace="http://xmlbeans.apache.org/ocastatus"
xmlns="http://xmlbeans.apache.org/ocastatus"
elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<xsd:element name="ocaStatus" type="OCASTATUS_TYPEType"/>
<xsd:complexType name="OCASTATUS_TYPEType" xdb:SQLType="OCASTATUS_TYPE">
<xsd:sequence>
<xsd:element name="status" type="STATUS_TYPEType" xdb:SQLName="status" maxOccurs="unbounded" xdb:SQLCollType="STATUS_V"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="STATUS_TYPEType" xdb:SQLType="STATUS_TYPE">
<xsd:sequence>
<xsd:element name="statusCode" type="xsd:double" xdb:SQLName="statusCode" xdb:SQLType="NUMBER"/>
<xsd:element name="statusDate" xdb:SQLName="statusDate" xdb:SQLType="VARCHAR2">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="userId" xdb:SQLName="userId" xdb:SQLType="VARCHAR2">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="50"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="comment" xdb:SQLName="comment" xdb:SQLType="VARCHAR2">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="100"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>Registering...
BEGIN
dbms_xmlschema.registerSchema(
schemaURL => 'ocastatus.xsd',
schemaDoc => xmltype(bfilename('XSD_DIR','ocastatus.xsd'), nls_charset_id('AL32UTF8')),
genTypes => true,
genTables => false
END;2) Table definition :
CREATE TABLE oca_status (
num NUMBER,
doc XMLTYPE
XMLTYPE doc STORE AS OBJECT RELATIONAL
XMLSCHEMA "ocastatus.xsd"
ELEMENT "ocaStatus"
VARRAY doc.xmldata."status" STORE AS TABLE oca_status_tab
CREATE INDEX oca_status_tab_idx1 ON oca_status_tab("statusCode");
CREATE INDEX oca_status_tab_idx2 ON oca_status_tab("statusDate");3) Inserting document...
INSERT INTO oca_status (num, doc)
VALUES(1, xmltype('<ocaStatus xmlns="http://xmlbeans.apache.org/ocastatus">
<status>
<statusCode>934</statusCode>
<statusDate>Wed Apr 07 16:05:53 GMT+05:30 2010</statusDate>
<userId>u0121845</userId>
<comment>Sent to LTC</comment>
</status>
<status>
<statusCode>934</statusCode>
<statusDate>Wed Apr 07 15:58:25 GMT+05:30 2010</statusDate>
<userId>u0121845</userId>
<comment>Sent to LTC</comment>
</status>
<status>
<statusCode>934</statusCode>
<statusDate>Wed Apr 07 15:54:02 GMT+05:30 2010</statusDate>
<userId>u0121845</userId>
<comment>Sent to LTC</comment>
</status>
<status>
<statusCode>750</statusCode>
<statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
<userId>u0121845</userId>
<comment>Document Metadata is correct.</comment>
</status>
<status>
<statusCode>934</statusCode>
<statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
<userId>u0121845</userId>
<comment>Sent to LTC</comment>
</status>
<status>
<statusCode>932</statusCode>
<statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
<userId>u0121845</userId>
<comment>Loaded to Novus</comment>
</status>
<status>
<statusCode>700</statusCode>
<statusDate>2010-03-31 12:39:41.580 GMT+05:30</statusDate>
<userId>u0121845</userId>
<comment>Document is deleted from OCA.</comment>
</status>
</ocaStatus>')
);Verifying index use (XPath rewrite) ...
SQL> EXPLAIN PLAN FOR
2 SELECT * from oca_status x
3 WHERE existsnode(x.doc, '//status[statusCode="934"]') = 1;
Explicité.
SQL> SELECT * FROM TABLE(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1840289382
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 7938 | 4 (25)| 00:00:01 |
|* 1 | TABLE ACCESS FULL | OCA_STATUS_TAB | 1 | 2145 | 4 (0)| 00:00:01 |
| 2 | NESTED LOOPS | | 1 | 7938 | 4 (25)| 00:00:01 |
| 3 | SORT UNIQUE | | 4 | 8580 | 2 (0)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID| OCA_STATUS_TAB | 4 | 8580 | 2 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | OCA_STATUS_TAB_IDX1 | 4 | | 1 (0)| 00:00:01 |
| 6 | TABLE ACCESS BY INDEX ROWID | OCA_STATUS | 1 | 5793 | 1 (0)| 00:00:01 |
|* 7 | INDEX UNIQUE SCAN | SYS_C00243981 | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("NESTED_TABLE_ID"=:B1)
5 - access("statusCode"=934)
7 - access("NESTED_TABLE_ID"="X"."SYS_NC0000900010$")
Note
- dynamic sampling used for this statement
25 ligne(s) sélectionnée(s).
SQL> Regards.
Maybe you are looking for
-
Pictures not loaded in a Web Page Composer site without admin role
Hello! I have got an new problem concerning SAP Web Page Composer. I have created an new site with some paragraphs and some pictures. The problem is when I, with admin role, access this site I am able to see everything. When another user, without adm
-
How to switch off CUSTOMIZING DISTRIBUTION ???
We have faced with the following problem: After deleting of all records concerning customizing objects from transaction SCDT_SETUP in SOLMAN, our satellite system keep on using RFC SM_<SId>CLNT<clnt>_BACK which is lead to SOLMAN. So when I am calling
-
How To: Turn Windows 8 Automatic Updates on or off
My numerous advanced degrees are not helping me resolve how to process information via Toshiba Service Station. There is NO Download key tho I am asked to press it to process info for CyberLink Power DVD... . Other updates (I guess) ask me to press
-
MP3 plugin controls not visible in Firefox 9
I have some MP3 files embedded on my website. When I browse to the site in Internet Explorer, the files show up complete with controls (play, pause, etc.). For the longest time, they've also worked in Firefox but now that I have upgraded to Firefox 9
-
Hello, I'm looking for some guidance on how BI can help me. I am a business analyst in a health solutions firm, but not proficient in SQL. However, I have to work with large data sets that just exceed the capabilities of Excel. Basically, I'm having