Hi @ll,

I'm working on an CM/DM solution that uses BaseX as the metadata repository. This isn't my first stab at a DM/CM system just that the XML database portion is new to me…

Now when trying to scale the system up I find that I have created at least one offending query:

count(
distinct-values(
let $item := doc('db')/repository/items/*//object
for $path in $item/paths/path
where starts-with($path/@name, '/Root/Temp/Import/')
return $item/@uuid
)
)

The '*/' could be replaced with 'documents/document' and 'folders', but that would be two separate queries and their individual times would still be offending.

The goal of the query is to list items placed into a certain folder structure represented by items in the database.

This seems like a straight forward query but I'm stumped at trying to get it to perform adequately.

Any suggestions?

/ Chris