Am 28.11.2018 um 10:45 schrieb chandra Sekhar:

Dear basex,

Please find attachment for sample xml,Like sample xml we are added multiple xml's to the collection .Below query is my XQuery ,It is taking huge time,Can we optimize this query.


My collection size is nearly 1.5 GB



let $entriesDisplay := 'Display All' 
 let $Rows := (collection("752150_Voice_OCTOBER-18_Billed")/SUBCUSTBRK[AccNo[@NO = (9800964)]][DOB >='2018-10-01'   and DOB <='2018-10-31'][ServInfo!=0])   
 
 let $accNo := "9800964"  
 let $accWiseTags := $Rows[AccNo[@NO = $accNo]]  
 for $servNos in distinct-values($accWiseTags/CONN/@NO)  
 let $eachRow := $accWiseTags[CONN[@NO=$servNos]] 
  
 return   $eachRow

Have you tried to use `group-by` e.g.

  for $r in $accWiseTags

  group by $no := $r/CONN/@NO

  return $r

?