Hi all,
I am surprised that fn:id() does take quite a long time in contrast to (almost) equivalent XPaths.
An example:
XQUERY collection('zk/')//id('zkI_108-5_R')
<div xmlns="http://www.tei-c.org/ns/1.0" xml:id="zkI_108-5_R"> ... </div> Query executed in 5956.43 ms.
XQUERY collection('zk/')//*[@xml:id='zkI_108-5_R']
<div xmlns="http://www.tei-c.org/ns/1.0" xml:id="zkI_108-5_R"> ... </div> Query executed in 9.43 ms.
Couldn't the first XQuery be optimized into the second? If not, maybe an xml:id index would be a good feature. eXist-db does have one, particularly dedicated to speed up fn:id() [1].
Best regards, Sebastian Zimmer
[1] http://exist-db.org/exist/apps/doc/indexing.xml
Hi Sebastian,
collection('zk/')//id('zkI_108-5_R')
…yields the same results as…
collection('zk/')/id('zkI_108-5_R')
…but the latter version should be much faster. Your first query is identical to:
collection('zk/')/descendant-or-self::node()/id('zkI_108-5_R')
This means that the fn:id function will be called for each node of the document (but as duplicates in a path expression will be removed, you will not get any duplicate nodes).
In BaseX, similar to eXist-db, the index is used to speed up evaluation, but eXist-db seems to better at optimizing the query in a way such that fn:id will only be evaluated once. Maybe I can introduce a similar optimization in BaseX, but for now, using a single slash should already help you out.
Cheers, Christian
<div xmlns="http://www.tei-c.org/ns/1.0" xml:id="zkI_108-5_R"> ... </div> Query executed in 5956.43 ms.
XQUERY collection('zk/')//*[@xml:id='zkI_108-5_R']
<div xmlns="http://www.tei-c.org/ns/1.0" xml:id="zkI_108-5_R"> ... </div> Query executed in 9.43 ms.
Couldn't the first XQuery be optimized into the second? If not, maybe an xml:id index would be a good feature. eXist-db does have one, particularly dedicated to speed up fn:id() [1].
Best regards, Sebastian Zimmer
[1] http://exist-db.org/exist/apps/doc/indexing.xml
-- <---------- Sebastian Zimmer sebastian.zimmer@uni-koeln.de
Cologne Center for eHumanities (CCeH)
- Universität zu Köln -
------------------------------------>
basex-talk@mailman.uni-konstanz.de