[nycphp-talk] Building trees
Hans Zaunere
lists at zaunere.com
Fri Jul 28 08:49:19 EDT 2006
csnyder wrote on Thursday, July 27, 2006 6:25 PM:
> On 7/26/06, Hans Zaunere <lists at zaunere.com> wrote:
> >
> >
> > Jim Hendricks wrote on Wednesday, July 26, 2006 9:32 PM:
> > > I've got somewhere in my library of routines a set of routines
> > > for trees using nested subsets. It worked with mysql and if I
> > > recall correctly the queries were all simple enough without the
> > > need for subqueries. I also seem to recall Hans working on a
> > > nested subset lib and discussing it on this list.
> >
> > An NSM related presentation a while back:
> >
> > http://www.nyphp.org/content/presentations/nyphp/index.php?slide=2
> >
> >
> > Old school code:
> >
> > http://cvs.nyphp.org/cvsweb.cgi/clew/Attic/pnsm.pcom
> >
> > http://cvs.nyphp.org/cvsweb.cgi/clew/lib/
> >
> >
> > And search here:
> >
> > http://www.nyphp.org/google.php
> >
> > for things like 'nsm' for a lot of discussion.
> >
>
>
> The NSM works great (I use it everywhere), but beware of long insert
> times in tables larger than 50,000 nodes.
One of the ways to deal with this is to introduce fragmentation. This book
is a must have:
http://www.amazon.com/gp/product/1558609202/002-4209242-6172841?v=glance&n=2
83155
Among other things, an interesting approach that he introduces is the
fragmentation of the nested sets. For instance, you start the nested set
numbering (ie, number line) in multiples of hundreds, when an insert comes
along, you only have to update the rows within your fragment. Then, on a
maintenance basis, you can renumber the entire numbering line to keep some
level of fragments. Joe Celko goes into details about this, the pros/cons,
and other techniques.
---
Hans Zaunere / President / New York PHP
www.nyphp.org / www.nyphp.com
More information about the talk
mailing list