Hi,
I do not know much about your schema, you should definitely consider defining indexes. Nevertheless, some remarks:
where $i/Info[tf:containsText(ZoneCode,'28') and tf:containsText(AdminCode,'01')]
first lets me wonder why you use tf:containsText rather than a simple equality (eq or =)
in addition, combining where and filter is possible, but gives the optimizer hard times. Alternatively, this could be stated as
for $i in input()/Petition
let $endDate := $i/endingDate
let $info := ( for $inf in $i/Info
where tf:containsText($inf/ZoneCode,'28') and tf:containsText($inf/AdminCode,'01'))
where $info and...
or, if you have only one Info node per document, even simpler:
for $i in input()/Petition
let $endDate := $i/endingDate
let $info := $i/Info
where tf:containsText($info/ZoneCode,'28') and tf:containsText($info/AdminCode,'01') and ...
respectivley, if text functionality is not really needed
for $i in input()/Petition
let $endDate := $i/endingDate
let $info := $i/Info
where $info/ZoneCode='28' and $info/AdminCode = '01' and ...
I any case, you should have an combined index on $info/ZoneCode and $info/AdminCode, a text index if text functionality is really needed, a standard index otherwise
next thing to wonder about is
xs:string($endDate) >= xs:string('2008-06-01 00:00:00') and xs:string($endDate) <= xs:string('2008-06-31 23:59:59')
why do you convert $endDate to String? Tamino can do comparison on dates. And also here, you might consider defining an index
#Tamino#API-Management#webMethods