Slow tf:getLastModified

Is there any way to get list of modified-in-period roots really fast?
If I use this query, it lasts more than 20 seconds.
Number of roots is about 250000.
There is index defined on Kzadeva/Kspis/@idZadeva.
Kzadeva schema definition is quite complex; many subelements with many attributes.

My xml query:
[b]declare namespace xs=“XML Schema
declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction
declare namespace ns1=“http://sodisce.si/schema/K/criminal_case/db/Kzadeva
declare namespace ns2=“http://sodisce.si/schema/K/criminal_case/db/Skupni
declare namespace brw=“http://sodisce.si/schema/K/criminal_case/sc/SCCaseBrwModifiedInPeriodResponse

let $changeDateFrom := xs:dateTime(“2011-05-03T00:00:00.000+02:00”)
let $changeDateTo := xs:dateTime(“2011-05-06T23:59:59.999+02:00”)

let $myCases:= for $case in input()/ns1:Kzadeva
let $lastModified := tf:getLastModified(root($case))
where $lastModified >= $changeDateFrom and $lastModified <= $changeDateTo
return $case/ns1:Kspis/@ns2:idZadeva

return element brw:RData
{
attribute brw:all { count($myCases) }
}[/b]

I think you are confusing the Xquery parser by nesting the getLastModified in a “for loop”.
A structure like the one below claims to be using indexing when I use “Explain”, but I haven’t tested performance in a 250K instance scenario :wink:
Finn

let $startdate:=xs:dateTime(“2011-05-10T13:54:00.999+02:00”)
let $enddate:=xs:dateTime(“2011-05-10T13:56:00.999+02:00”)
for $q in input()/testNode
where tf:getLastModified($q) > $start and tf:getLastModified($q) < $enddate
return $q