Subject:XQuery Nested Loop Lookup Author:Rick Scofield Date:09 Feb 2014 10:27 AM
Need some help with a Xquery nested loop. Both files are about 30k lines long and growing. I'm trying to match the <Sku> value in the $mivabod file with the <upc> value in the $carhbod file and return the <sku> or <upc> and the <qtyavail> from the $carhbod file. I have the xquery code here that takes about 30min to complete.
something like...
SELECT $carhbod/qtyavail FROM $carhbod WHERE $mivabod/Sku = $carbod/upc
Can anyone help with a more efficient way to do this?
This xQuery takes way too long...
===begin code===
declare variable $mivabod as document-node(element(*, xs:untyped)) external;
declare variable $carbod as document-node(element(*, xs:untyped)) external;
<root>
{
for $miva in $mivabod/table/row/Sku
for $carh in $carbod/root/row[upc = $miva]
return
<carqty>
<UPC>{$miva/text()}</UPC>
<quantity>{$carh/qtyavail/text()}</quantity>
</carqty>
}
</root>
===end code===