<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Mircea,<DIV><BR class="khtml-block-placeholder"></DIV><DIV>This sounds interesting.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>How would you do this, would you subclass the current JDBCCacheLoader, or would you rewrite it as a new cache loader?  (I'd still want to leave the current JDBCCacheLoader in tact for compat reasons, etc).  Either way, if you don't mind going ahead with an impl and put it through some tests comparing it with the existing JDBCCacheLoader, we certainly would appreciate it.  :-)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Cheers,</DIV><DIV><DIV><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>--</DIV><DIV>Manik Surtani</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Lead, JBoss Cache</DIV><DIV>JBoss, a division of Red Hat</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Email: <A href="mailto:manik@jboss.org">manik@jboss.org</A></DIV><DIV>Telephone: +44 7786 702 706</DIV><DIV>MSN: <A href="mailto:manik@surtani.org">manik@surtani.org</A></DIV><DIV>Yahoo/AIM/Skype: maniksurtani</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN></SPAN> </DIV><BR><DIV><DIV>On 21 Jan 2007, at 19:42, Mircea Markus wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite">Hi guys,<BR><BR>I've took a look at the implementation of JDBCCacheLoader and here are some thoughts on it. <BR><BR>There is an alternative way of persisting trees into the database. It has certain advantages compared to the straight forward solution of each node keeping a reference to its parent ( a.k.a. Adjacency List Model). The basic idea is to traverse the tree in preorder and add some indexing info to each node - you can find a nice and simple description of the model here: <A href="http://www.sitepoint.com/print/hierarchical-data-database" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> http://www.sitepoint.com/print/hierarchical-data-database</A>.  This indexing info will be further used for optimizing fetching and removing operations.<BR><BR>The big advantage is that all the recursive calls for the loadSubtree and removeSubtree operations are nicely avoided. Drawback - insertions is slightly more time consuming. <BR><BR>I've made a comparison between this approach and the existing implementation and here are some figures. Methods that are affected are: remove(Fqn), loadState(Fqn subtree, ..) and put(Fqn, value)<BR><BR>1) remove(Fqn). Current recursive implementation performs about pow(m,n) database calls. M = the average # of children, n the depth of the subtree. The new approach would reduce it to a fix value(3 calls - retrieve the node, delete it together with all its children, update indexes) <BR>2) loadState(Fqn subtree, ..) - similar to remove; pow(m,n) database calls, 2 queries for loading it.<BR>3) put(Fqn, value) - here is the drawback. Normally a new update should be performed in order to shift the indexes. An optimization can be performed though. By indexing with a step of lets say 10, we'll be assured that the next 9 insertion will not conflict, so the drawback would be an update for  each 9 insertions - not  a big deal I would say. <BR><BR>If you guys find it usefully, really glad to go ahead with an implementation and compare the performance figures...<BR><BR>Cheers,<BR>Mircea<BR><BR> <BR><BR><BR><BR><BR><BR><BR><BR><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">jbosscache-dev mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:jbosscache-dev@lists.jboss.org">jbosscache-dev@lists.jboss.org</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="https://lists.jboss.org/mailman/listinfo/jbosscache-dev">https://lists.jboss.org/mailman/listinfo/jbosscache-dev</A></DIV> </BLOCKQUOTE></DIV><BR></DIV></DIV></BODY></HTML>