I'm trying to use KODO JDO and found an interesting phenomenon.I would like to understand why it happend. I have four mapped classes that each of their instances can be related or to an instance of the same class or to the next class.(this four classes can be understood as a tree structure - as following (for classes a,b,c,d) the instances may be related as following - a1(a2(a5(b4(b6,c1(c2(d2(d5(d7),d6),d3),c3,d1)),b5),b1,b2),a3(a6,a7,b3),a4) The big question is the way I should map the objects, should I define a collection of the children in each parent or should I put only the 'parent' field in each child (and get the children when needed by a queries). I tried that and found that the first way (map collections of the children) was significantly better. I test the case by getting all the children from the highest level to the lowest and got (5532 msec in the first option and in the second I got the answers in 12375 msec - I write here the performance for the first time check, after that the cache 'helped' the performance). The way I did that for the first option was just to get the attribute of the children collection, get the children of the highest level parent and then get the children's children ect.(I think that all the children levels were already populated after the highest parent was fetched?!) The way I did that for the second option was query recursively the children by the (parent = 'x'). Why did I get such a difference between those cases. I thought that the queries performance should be the same as having mapped collections of children - after all teh same sqls should be performed, isn't that true?! how can I explain the difference in the performance?
The SQL will not be the same as each depth in the tree requires another join. This is one of the major limitations of relational databases, that each relation requires another join regardless of being the same (sub) class. However, Kodo can more eagerly fetch this depth based on EagerFetchMode settings as well as your metadata.
For faster response times to Kodo specific queries, you can also contact our engineering staff directly at jdosupport@solarmetric.com.
Best Regards, Neelan Choksi neelan@solarmetric.com