Re: Fast tree scan
Re: Fast tree scan
- Subject: Re: Fast tree scan
- From: Paul Suh <email@hidden>
- Date: Wed, 31 May 2006 16:16:49 -0400
Flor,
Two things spring to mind.
The first is to just have the entity cached in RAM via the setting in
EOModeler. Select the entity, inspect it, and go to the advanced
entity inspector (the second icon), and select the checkbox at the
bottom that says, "Cache in Memory". This will pull in all of the
snapshots for the entity, and then when you traverse the tree the
EO's are generated from the cached snapshots and you avoid the round
trip to the database. This works best if you are going to traverse
all of the trees and there aren't so many individual EO's that you
start running out of RAM.
The second technique is to set a prefetching key path. This is made
really easy because you already have a single separate root object
that has a to-many relationship to all of the nodes of a particular
tree. Fetch that root node, but in the fetch specification set a
prefetching key path that follows the to-many relationship and gets
all of the nodes into memory in one round-trip to the database. This
works best if you are going to traverse only one or a few of many
trees, or if there are so many nodes that you can't cache them all in
memory.
Hope this helps.
--Paul
Paul Suh
http://www.ps-enable.com/
email@hidden (301) 643-1516
On May 31, 2006, at 11:21 AM, Florijan Stamenkovic wrote:
Hi all,
I have an entity that relates to itself, having a parent and
children of the same entity. It works fine.
The intention is that the tree can be used to indefinite depth,
with an indefinite amount of branches. Practically, this measures
let's say ten levels of depth, and involved hundreds of nodes. And
there can be quite a number of trees managed.
At one point however I need to scan the whole tree. That takes a
while because of EOF faulting, where children are not resolved
until they are asked for. Since this is used in a Java Client
scenario, that means that the children for every node cause a trip
to the application server to get the data. It is immensely cheaper
to get it all in one.
My solution was to relate every node to the root node, which is of
a different entity. That way all the nodes belonging to the same
tree can be resolved through one request, regardless of how deep
they are. This however does not help me, because still the children
for every node are faults, and still a round trip is made when I
resolve them.
So, the question is: does anybody know how this can this be
optimized, so that I don't have to have so many round trips?
TIA,
Flor
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >Fast tree scan (From: Florijan Stamenkovic <email@hidden>) |