compound index and count()

Hi, I have the following scheme:

<?xml version = "1.0" encoding = "UTF-8"?>

<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

Sorry, I give you the scheme withou compound index. The correct scheme is:

<?xml version = "1.0" encoding = "UTF-8"?>

<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:adminInfo
tsd:server4.2.1.1</tsd:server>
tsd:modified2005-09-13T15:59:08.951+01:00</tsd:modified>
tsd:created2005-09-13T15:59:08.951+01:00</tsd:created>
tsd:versionTSD4.2</tsd:version>
</tsd:adminInfo>
</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:annotation
xs:appinfo
tsd:elementInfo
tsd:physical
tsd:native
tsd:index
tsd:standard
<tsd:field xpath = “User”></tsd:field>
<tsd:field xpath = “Type”></tsd:field>
</tsd:standard>
</tsd:index>
</tsd:native>
</tsd:physical>
</tsd:elementInfo>
</xs:appinfo>
</xs:annotation>
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>

but the problem is the same

Hi,

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.

Best Regards,

Thorsten Fiebig

Hi,

I have a similar problem

My query is

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…

Thank you.

Hi,

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.

Best Regards,

Thorsten Fiebig