Hi,

I am trying to get all distinct start element '/products/p:category/start' nodes of a big file. I have written a query which is given below. It is taking to long to get the result. I am attaching the query info and the xml file. 

After Running couple of minutes, I stopped the execution.

 Query is trying to get all the distinct start elements 

 There are 3 lac category elements.

declare namespace functx = "http://www.functx.com";
declare namespace p="a:b:c";


declare function functx:is-node-in-sequence( $node as node()? , $seq as node()* )  as xs:boolean {some $nodeInSeq in $seq satisfies deep-equal($nodeInSeq,$node)};

declare function functx:distinct-nodes( $nodes as node()* ​
​)  as node()* {for $seq in (1 to count($nodes))return $nodes[$seq][not(functx:is-node-in-sequence(.,$nodes[position() < $seq]))]} ;
 
let $diff_starts := functx:distinct-nodes(/products/p:category/start)
return $diff_starts 

Please let me know if you require further details.