Performance issue with XML cross apply:
DataTable has 1300 entries and the field xmldata has 250 nodes, so the query is running 1300 * 250 times to brings the output and the execution times takes a while.. about an hour to generate 325000 rows. Does anybody face a similar issue with the large dataset? Your help is highly appreciated.
Sample XML:
<dataModel>
<Colum1>
<value />
<displayText />
<controltype>textbox</controltype>
<label>Field1</label>
<controlid>4458575-b0d3-ff4d-01ac-5447e21234dd</controlid>
</Colum1>
<Colum2>
<value />
<displayText />
<controltype>textbox</controltype>
<label>Field2</label>
<controlid>5a5b7b7e-7b66-1f0d-a562-9d0660a74e11</controlid>
</Colum2>
....
</dataModel>
select t.c.value('(local-name(.))[1]', 'nvarchar(100)') as keyname ,
t.c.value('(controlid)[1]', 'nvarchar(200)') as controlid,
t.c.value('(label)[1]', 'nvarchar(500)') as label
from DataTable xmldata
CROSS APPLY xmldata .nodes('/dataModel/*') T(c)
Thanks