I have a similar situation in which I want to get all distinct values of a specific attribute. I’ve tried using 2 different approaches: group and distinct-values. On small or medium size databases group tends to be faster. When trying to get distinct values of a specific attribute from large databases however both approaches are timing out for me. I’m looking for a way to optimize this query:
distinct-values(for $db in db:list() return distinct-values(db:open($db)//@sec-type))
index:texts("dbname","type:") to get a distinct list of types all be it with a prefix that would need adjusting logic in using that data or querying.