(: rewritten to :)
db:text('factbook', 'Shenzhen')/parent::name
</syntaxhighlight>
If multiple candidates for index access are found, the database statistics (if available) are consulted to choose the cheapest candidate:
<syntaxhighlight lang="xquery">
db:open('factbook')/mondial/country
[religions = 'Muslim'] (: yields 77 hits :)
[ethnicgroups = 'Greeks'] (: yields 2 hits :)
(: rewritten to :)
db:text('factbook', 'Greeks')/parent::ethnicgroups/parent::country[religions = 'Muslim']
</syntaxhighlight>