<xs:schema xmlns:tsd = “http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition” xmlns:xs = “XML Schema”> xs:annotation xs:appinfo
<tsd:schemaInfo name = “Docs”>
<tsd:collection name = “test”></tsd:collection>
<tsd:doctype name = “Document”> tsd:logical tsd:contentclosed</tsd:content>
</tsd:logical>
</tsd:doctype>
</tsd:schemaInfo>
</xs:appinfo>
</xs:annotation>
<xs:element name = “Document”> xs:complexType xs:sequence
<xs:element name = “Total” type = “xs:string”> xs:annotation xs:appinfo tsd:elementInfo tsd:physical tsd:native tsd:index tsd:standard</tsd:standard>
</tsd:index>
</tsd:native>
</tsd:physical>
</tsd:elementInfo>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name = “AccessControl” minOccurs = “0” maxOccurs = “unbounded”> xs:complexType xs:sequence
<xs:element name = “User” type = “xs:string”></xs:element>
<xs:element name = “Type” type = “xs:string”></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
As you can see, I use standard index for “Total” element and a compound index hosted
in “AccessControl” element.
My queries are:
let $c := (for $b in input()/Document
for $a in $b/AccessControl
where ($a/User=“0”
and
$a/Type=“view”)
return $b)
return count($c)
and
let $c :=(for $b in input()/Document
where ($b/Total=“500”)
return $b)
return count($c)
the response of both queries must be 20000 (and the same documents), but response time are very different:
First query: about 8 seconds (!?!?!?)
Second query: less than 1 seconds (:D)
which is the difference ? both elements are indexed !
and more, if I delete the compound index of the scheme, response time for the first query is the same (8 seconds)
I need to use the first query in my aplication and I will manage much more than 20000 documents.
Thanks
I’ve successfully reproduced your problem. From my point of view it is a problem of the Tamino XQuery processor.
Please contact your local Software AG support and raise a support issue.
let $v:=(for $a in input()/EN_RECURSO_HUMANO
let $b:=count($a/EN_FORMACAO)
where $b=3
return
$b)
return
{count($v)}
In a small database (5000 documents) this query works fine, but in a medium sized database (1000000 documents) I get “Transaction aborted because it has taken too long”.
What was the solution to your problem? Maybe your solution can help me…
I think your problem is quite different. You are trying ro retrieve nodes by a predicate regarding the number of certain child elements. Unfortunately there is no index support in Tamino for this kind of queries. Without index support a query will run sufficiently fast on a large database.
A solution might be that you store the number of the child elements in an attribute and defining a standard index on it.