質問

I have a large xml stream I pass to a stored procedure, but I'm getting a long response time of almost 1.30 minutes on a specific part of the xml which gets repeated alot.

I've checked the Execution Plan, and 2 sections of the xml structure takes up almost all of the processing time. I've also tried reading it into 2 temp tables first, before doing the insert, not that it helped. The XML is 368Kb in size, so I have a strong suspicion my xml is either wonky or i'm missing something to help ease the parsing.

Is there a better way to formulate the xml, to make it easier for Xpath() to parse? I really have no idea what else to do.

The structure of the xml is:

<root>
<someobject>
 <param1></param1>
 <param1></param1>
</someobject>
<somethingelse>
 <param1></param1>
 <param1></param1>
</somethingelse>
<row1>
  <param1></param1>
  <param1></param1>
  <param1></param1>
  <param1></param1>
  <param1></param1>
  <param1></param1>
  <param1></param1>
  <param1></param1>
</row1> 

The query I currently use:

Insert Into [Table] 
Select   
  XmlParam.Doc.value('fieldA[1]','UNIQUEIDENTIFIER')
,XmlParam.Doc.value('fieldB[1]','UNIQUEIDENTIFIER')
,XmlParam.Doc.value('fieldC[1]','UNIQUEIDENTIFIER')
,XmlParam.Doc.value('fieldD[1]','UNIQUEIDENTIFIER')
,XmlParam.Doc.value('fieldE[1]','UNIQUEIDENTIFIER')
,XmlParam.Doc.value('fieldF[1]','UNIQUEIDENTIFIER')
,XmlParam.Doc.value('fieldG[1]','bit')
,XmlParam.Doc.value('fieldH[1]','bit')
      From @Xml.nodes('//Flow/StepData') XmlParam(Doc)  

Thanks for the help!

役に立ちましたか?

解決

Try this, it might be faster for you.

Select   
   XmlParam.Doc.value('(fieldA/text())[1]','UNIQUEIDENTIFIER')
  ,XmlParam.Doc.value('(fieldB/text())[1]','UNIQUEIDENTIFIER')
  ,XmlParam.Doc.value('(fieldC/text())[1]','UNIQUEIDENTIFIER')
  ,XmlParam.Doc.value('(fieldD/text())[1]','UNIQUEIDENTIFIER')
  ,XmlParam.Doc.value('(fieldE/text())[1]','UNIQUEIDENTIFIER')
  ,XmlParam.Doc.value('(fieldF/text())[1]','UNIQUEIDENTIFIER')
  ,XmlParam.Doc.value('(fieldG/text())[1]','bit')
  ,XmlParam.Doc.value('(fieldH/text())[1]','bit')
From @Xml.nodes('//Flow/StepData') XmlParam(Doc)  
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top