XQuery Count Function Poor Performance

Greetings,
I am using The Interactive Interface to get a total count of the documents.

Pointing to the same database, collection and document.

My X-Query would finish in sub-second.
count(/Doc)

But my equivalent XQuery would run until it times out after 15 minutes.
let $a:=count(for $b in input()/Doc return $b)
return $a

I don’t understand why is XQuery function count() so different.

Hi,

The XQuery should show nearly the same performance as the X-Query. Could you please tell me which Tamino version you are using?

Best Regards,

Thorsten

Hello,

I am testing Tamino 4.2.1.8 on Z/Linux with SuSe 2.4.
And I am also getting similar result on Windows 2K3 with Tamino 4.2.1.1.

With the XQuery, all I can see is the system CPU resource taken up by
inosrv, but can’t tell what went on inside the Tamino.

Do you know of any utility that allows us to see what Tamino is doing internally ?

Do you know whether X-Query and XQuery requests are handled by the same or different internal process ?

I’ve tried unload/reload data, undefine/define schemas.

Thanks.

Hi,

It would be interesting if you could perform the tests with Tamino 4.2.1.8 on Windows 2K3.

To get an explanation you can put {?explain?} in front of your query. This will show you the query execution plan that is executed by the Tamino XQuery processor to retrieve the query result. In order to understand the explain output it might be helpful to read the paper:

http://www-rocq.inria.fr/gemo/Gemo/Projects/XIME-P/CR/PDF/FiebigCR.pdf

It describes the basic concepts of the Tamino XQuery processor.

The XQuery and X-Query request are handled by different processors.

Best Regards,

Thorsten

Hello,

Thank for your article, I’ve realized a big difference in fundamental between Tamino XQuery and relational SQL (where I came from).

Actually, my XQuery was like this:
let $b:=count(for $a in input()/doc return $a/element1)
return $b

‘element1’ has both standard and text index defined.
I was assuming by returning ‘$a/element1’, this would enhance the optimizer since it would work similar to a ‘covering’ index in SQL, where the data is already covered or made available by the index, it doesn’t cost any extra to retrieve it.

Little did I know, index in Tamino only provides access to the documents, not for retrieving data. I guess there are no such thing as covering index due to the nature of hierchical data.

Now the XQuery count works fine:
let $b:=count(for $a in input()/doc return $a)
return $b

Thanks.