Thanks again, Christian. Regardless of whether I have the UPDINDEX and AUTOOPTIMIZE options enabled, I'm seeing that my first set of updates runs pretty quickly (in about 90 seconds) but any subsequent set of updates hangs indefinitely -- I let it run for over 2 hours and it never completed. Do you have any idea what could be going on?

On Mon, Jul 26, 2021 at 9:41 PM Christian Grün <christian.gruen@gmail.com> wrote:
> Thank you Christian and Graydon! I've got a solution working by calling the script multiple times to do only a subset of the updates each time. On a different (though related) note, do I understand correctly that I should run a "db:optimize($db)" after each time I perform a significant amount of updates?

It’s definitely advisable if you perform queries that take advantage
of the BaseX index structures – which is already the case for
root/element[@id = $se/@id]. If the UPDINDEX option is enabled, the
index structures will always be kept up-to-date (but again, a database
optimization might be recommendable to minimize the index structures).