TL
R: I am using Alfresco 5.1 and I was wondering if there is a way to optimize queries to the nodeservice in case of a large query involving a bunch of nodes and properties.
For example, say that I have this model:
<model name="My model" xmlns="http://www.alfresco.org/model/dictionary/1.0">
...
<type name="ParentNode">
<title>The parent that i want to retrieve</title>
<parent>cm:cmobject</parent>
<associations>
<child-association name="ParentChildA">
<source>
<mandatory>true</mandatory>
<many>false</many>
</source>
<target>
<class>ChildA</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
<duplicate>false</duplicate>
</child-association>
</associations>
</type>
<type name="ChildA">
<title>First layer of children</title>
<parent>cm:cmobject</parent>
<properties>
<property name="ChildAName">
<type>d
tring</type>
<mandatory>true</mandatory>
</property>
</properties>
<associations>
<child-association name="ChildAChildB">
<source>
<mandatory>true</mandatory>
<many>true</many>
</source>
<target>
<class>ChildB</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
<duplicate>false</duplicate>
</child-association>
</associations>
</type>
<type name="ChildB">
<title>Second layer of children</title>
<parent>cm:cmobject</parent>
<properties>
<property name="ChildBName">
<type>d
tring</type>
<mandatory>true</mandatory>
</property>
<property name="ChildBOtherProperty">
<type>d
tring</type>
</property>
</properties>
</type>
</model>
I need to create a list of all ChildA nodes that are children of the ChildAssociation "ParentChildA" for a certain node of type ParentNode. So for one specific "ParentNode", I need to get all its ChildA children and all ChildB children of those ChildA nodes.
The way i would normally go about this would be to get the NodeRef of the ParentNode and use the NodeService getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) to get the ChildA nodes, and then get the ChildB nodes again using the same method. Then i would get the properties of those nodes using the getProperties(NodeRef nodeRef).
This is really slow however. With about 80 nodes the request takes 3-4 seconds to complete. My guess is that each call to getProperties is its own database query.
So I am wondering, if there is a way to submit tne entire request to the database at once, instead of firing a request for each node? The database seems reasonably well indexed, so the waiting time should really not be this long.
Thank you for any help you can provide 