Join query performance

Hello,
I have two schemas Appointments and Patient. I run a join query between these two schemas and the response is very slow.

Appointment schema has about 20 documents and a standard index on Registration and UserCode fields.
Patient schema has about 40000 documents and a standard index on @Registration

I dont understand why query is so slow since I have all required indexes.

My query is like this and runs very slow :
for $a in input()/Appointments , $b in input()/Patient
where $a/Registration = $b/@Registration
and $a/UserCode = “msa”
return
{ $b/ID/Name} { $b/ID/Surname} { $a/Registration} { $a/StartDate} { $a/EndDate} { $a/Subject}

Some Other Interesting Notes :

This query also runs very slow (about 8 minutes) :for $a in input()/Appointments , $b in input()/Patient
where $a/Registration = $b/@Registration
and $a/UserCode = “msa”
return
$a

This query runs very fast : (less than 1 second)
for $a in input()/Appointments , $b in input()/Patient
where $a/Registration = $b/@Registration
and $a/UserCode = “msa”
return
$b/ID/Name

I am sending the Tamino request log as an attachment in case it may help
Tamino.AAC.log.1.xml (6.78 KB)

Hi,

The major difference between the two queries is that the first one returns complete Appointment document where the second just returns a Name element. How many Appointment documents are returned by the first query and how big are they?

Best Regards,

Thorsten

Hi Thorsten,

Only 4 or 5 Appointment documents return as a result and they are very small it has only 10 fields a sample Appointment document is like this

test MSA 1 1170243016000 1170243016000 normal MSA1170847833593 test

Besides this Patient document is quite a complex document with too many fields

Hi,

It seems that the result size can not give a proper explanation for the performance difference. From your XML request log I got the information that you are using an outdated Tamino 4.4. Please try again with the latest Tamino 4.4 update kit. If the problem still persists please send me the explain output for your queries.

Thanks & regards,

Thorsten