我试图通过替换某些
for
let
和
concat()
:
xquery version "3.1";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare variable $people-collection := doc("/db/apps/deheresi/resources/documents/codes_people.xml");
let $data-collection := "/db/apps/deheresi/resources/documents"
for $msdoc in collection($data-collection)/tei:TEI[contains(@xml:id,'ms609')]
let $concat1 := concat('<td>',
$msdoc//tei:div[@type='registry_ordinal']/replace(@n, '#', ''),
'</td><td>',
$msdoc//tei:div[@type='doc_type']/replace(@subtype, '#', ''),
'</td><td>',
$msdoc//tei:div[@type='folio']/replace(@n, '#', ''),
'</td><td>')
(: obtain the attribute value of persName[@role = 'dep']/@nymRef :)
let $nameref := $msdoc//tei:persName[@role = 'dep']/replace(@nymRef, '#', '')
(: now use the attribute value to lookup a printable name using xml:id in document codes_people.xml :)
let $persname := normalize-space(string-join($people-collection//tei:person[@xml:id = $nameref]))
return concat($concat1,$persname,'</td>')
这些调整使查询执行时间缩短了0.5秒(现在是3.5秒)。
$persname
)查询将在.17秒内执行。文件的查找
codes_people.xml
似乎是瓶颈。
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index xmlns:tei="http://www.tei-c.org/ns/1.0">
<range>
<create qname="tei:persName" type="xs:string"/>
<create qname="tei:person" type="xs:string"/>
</range>
</index>
<triggers>
<trigger class="org.exist.extensions.exquery.restxq.impl.RestXqTrigger"/>
</triggers>
</collection>
从查询探查器查看: