简体   繁体   English

在Oracle 10g中对ExtractValue进行性能调整

[英]Performance tuning for extractvalue in oracle 10g

There is an XML file (20MB), when i try to extract the values using the select statement from the table using the EXTRACTVALUE its taking a very long time(Hrs). 有一个XML文件(20MB),当我尝试使用EXTRACTVALUE从表中使用select语句提取值时,需要花费很长时间(Hrs)。 The table contains the XML_DATA as XMLTYPE Please suggest me to tune the SQL QUERY OR any other alternative to extract the values from the large xml file 该表包含XML_DATA作为XMLTYPE请建议我调整SQL QUERY或任何其他替代方法以从大型xml文件中提取值

SELECT EXTRACTVALUE (VALUE (Name),'*/Name') FirstName,  
.....   
FROM TB_XML_type,TABLE (XMLSEQUENCE (EXTRACT (xml_data, '*/Name'))) Name

Note : The XML format is user defined. 注意: XML格式是用户定义的。

Setting up a table like yours: 像您一样设置一张桌子:

CREATE TABLE TB_XML_TYPE(XML_DATA XMLTYPE);

INSERT INTO TB_XML_TYPE(XML_DATA) 
VALUES (XMLTYPE('<a><Name>name1</Name><Name>name2</Name></a>'));

I am guessing the Name element is right under the root element in your XML. 我猜想Name元素就在XML的根元素下。 If that's the case, this may be faster. 如果真是这样,这可能会更快。

SELECT XD.NAME FROM TB_XML_TYPE XT, 
    XMLTABLE('/a/Name' PASSING XT.XML_DATA
        COLUMNS NAME VARCHAR2(100) PATH 'text()') XD

Result: 结果:

NAME                                                                                               
---------------------
name1                                                                                                
name2                                                                                                

If not, make sure the repeated path is right after XMLTABLE - this is the XPath that finds all the parent elements whose children you then read with the XPath right after the PATH keyword. 如果不是,请确保重复的路径就在XMLTABLE之后-这是XPath,用于查找所有父元素,然后在PATH关键字之后使用XPath读取其子元素。 In this case, text() reads the text contents of the Name element. 在这种情况下,text()读取Name元素的文本内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM