==Loop Unrolling==
{{Mark|Introduced with Version 9.6:}}
Loops with few iterations are ''unrolled'' by the XQuery compiler to enable further optimizations:
(: rewritten to :)
1 ! (. * 2), 2 ! (. * 2)
(: further rewritten to :)
1 * 2, 2 * 2
where $t/buyer/@person = $p/@id
return $t
return <item person='"{ $p/name/text() }'">{ count($a) }</item>,
(: rewritten to :)