Hello,
we are experiencing a weird performance issue in function calling.
In many xqueries we use, we found that calling functions slows
down the execution, sometimes it even hangs "forever".
I tried to drill down to the problem and I think I isolated an odd
behavior.
Before presenting the example code, let me summarize a little bit:
inside a for-loop we call a thousand times a function passing some
parameters.
I declared 3 functions, 2 of which take 1 parameter and the last
one takes 2 parameters.
For simplicity's sake the parameter "objectId" is never used, but
that doesn't affect the experiment.
When I call any of the 1-parameter functions, execution takes less
than 2 seconds, but when I call the 2-parameter function it runs
endlessly.
It seems that the combination of those two parameters is the point
of performance issue.
I hope you can illuminate me.
Regards
William
Here it is an example:
declare namespace xbpr = "http://www.bpeng.com/";
declare variable $amlDocName as xs:string :="aml";
declare variable $cxnDefsDocName as xs:string :="cxnDefsDocName";
declare function xbpr:testFast1($objectId as xs:string?){
let $docName := $cxnDefsDocName
let $conn_typeof_target :=
doc($docName)/CxnDefs/CxnDef[@type="RdfsType"]/@target
return $conn_typeof_target
};
declare function xbpr:testFast2($docName as xs:string?){
let $conn_typeof_target :=
doc($docName)/CxnDefs/CxnDef[@type="RdfsType"]/@target
return $conn_typeof_target
};
declare function xbpr:testSlow($docName as xs:string?, $objectId
as xs:string?){
let $conn_typeof_target :=
doc($docName)/CxnDefs/CxnDef[@type="RdfsType"]/@target
return $conn_typeof_target
};
let $instances := doc($amlDocName)/AML/Group//ObjDef
for $instance in $instances
let $objectId := $instance/@ObjDef.ID
let $v := xbpr:testFast1($objectId)
let $v := xbpr:testFast2($cxnDefsDocName)
let $v := xbpr:testSlow($cxnDefsDocName, $objectId)
return $v