Bad XQuery update performance

I have a fairly big xml document(6.8M) with schema defined together in my Tamino collection. I need to execute a XQuery update to insert a new attribute to this document. The document is the only document in this collection.The syntax is :

update insert attribute test {“value”} into /Notebook/div/i[@xid=“110”]

this command took about 8 seconds to finish. Eventhough I already created index on attribute “xid”, and the explains shows that the processor indeed used the index. I also tried to create index on “i”, still the same thing.

I don’t know whether this is the best Tamino can do, or we can do something to improve this XQuery command. Finally, I will need to insert this new attribute to
thousands of elements in this document. that will cost hours of work.

Hi,

first of all, indexes will not help you in this scenario. Indexes are used to select the requested documents from the set of all documents in a doctype. However, they do not support navigation within a document.

In the current implementation, XQuery update rewrites the complete document (i.e., 6.8M in your case) after the requested modifications have been applied.

Have you tried to do multiple update operations in one XQuery statement? For example:

for $a in input()/Notebook
do ( insert attribute test {“value”} into $a/div/i[@xid=“110”]
insert attribute test {“value”} into $a/…

)

This should have the same execution time as a single insert.

Hope this helps,
Best regards,
Manfred Michels

Hi, thanks for clearing things with me.

  1. When I don’t have a schema defined, the single update of the document takes about
    30 seconds. After I defined a schema with this document, the same update takes about
    only 8 seconds. Why the schema helps the update? I only have one single document
    in my collection.

  2. I tried to put update commands into one single update as you mentioned. and found out
    5 update commands in a single udpate-----------each update takes average 3.7 seconds
    10 update commands in a single udpate-----------each update takes average 3.7 seconds
    15 update commands in a single udpate-----------each update takes average 11 seconds
    if I put more udpate commands into it, it seems like it take forever…