Subsequent rewritings might result in query plans that differ a lot from the original query. As this might complicate debugging, you can disable function inling during development by setting {{Option|INLINELIMIT}} to {{Code|0}}.
==Loop Unrolling==
{{Introduced with Version 9.6:}}
Loops with few iterations are ''unrolled'' by the XQuery compiler to enable further optimizations:
<syntaxhighlight lang="xquery">
(1 to 2) ! (. * 2)
(: rewritten to :)
1 * 2,
2 * 2
(: rewritten to :)
2, 4
</syntaxhighlight>
The standard unroll limit is <code>5</code>; it can be adjusted via the {{Option|UNROLLLIMIT}} option:
<syntaxhighlight lang="xquery">
(# db:unrolllimit 100 #) {
for $i in 1 to 10
return $i * $i
}
(: rewritten to :)
1 * 1,
2 * 2,
...
</syntaxhighlight>
Care should be taken if a higher value is selected, as memory consumption and compile time will increase.
==Paths==
=Changelog=
;Version 9.6
* Added: {{Option|UNROLLLIMIT}}
Introduced with Version 9.4.