I’ve got a report using XQuery, which takes way too long. The reason is simple: Basically, the report iterates over a large result set. For every iteration, some subqueries are issued. For example, every result item has got a classification, and a query is used to replace the classifying objects UUID with its name.
A better solution would be something like this: At the top of the query, extract the whole taxonomy from the database, and store it in some kind of data structure. (A map comes to mind.) Then, within the loop, replace the subquery with a simple lookup into the data structure.
Can I do this somehow in XQuery? Simple example, or documentation?