Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8507F476127 for ; Wed, 4 Sep 2002 13:52:41 -0400 (EDT) Received: from mailout05.sul.t-online.com (mailout05.sul.t-online.com [194.25.134.82]) by postgresql.org (Postfix) with ESMTP id D26DC475921 for ; Wed, 4 Sep 2002 13:52:40 -0400 (EDT) Received: from fwd10.sul.t-online.de by mailout05.sul.t-online.com with smtp id 17meKV-00026n-00; Wed, 04 Sep 2002 19:52:39 +0200 Received: from fraxinus.reticulum (520013531845-0001@[217.225.152.164]) by fmrl10.sul.t-online.com with esmtp id 17meKG-0yFMMCC; Wed, 4 Sep 2002 19:52:24 +0200 Received: from ks by fraxinus.reticulum with local (Exim 3.35 #1 (Debian)) id 17meED-0000t2-00 for ; Wed, 04 Sep 2002 19:46:09 +0200 Date: Wed, 4 Sep 2002 19:46:08 +0200 From: knut.suebert@web.de To: pgsql-sql@postgresql.org Subject: Re: tree structures in sql - my point of view (with request of comment from joe celko) Message-ID: <20020904174608.GA3296@fraxinus.reticulum> References: <20020903132207.GC24879@depesz.pl> <200209031117.38107.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <200209031117.38107.josh@agliodbs.com> User-Agent: Mutt/1.4i X-No-Archive: yes X-Sender: 520013531845-0001@t-dialin.net X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/22 X-Sequence-Number: 9299 Josh Berkus schrieb: > Adjacency list trees are easier to understand conceptually, there are more > tools on freshmeat.net for them, and they are the most efficient form of tree > for graphical display. Hi, for graphical display it may be (the application to display could do the work), but displaying data in tables (or tabulars, if you prefer LaTeX-Syntax) leeds to recursion, I'd say. > Nested Set trees are hard to wrap your mind around, Yes ;-) > lack a lot in the way of code samples on freshmeat, are harder to > build GUI tools for, but are much, much faster for determining > branch membership and branch parenthood. While wrapping around my mind to understand Nested Sets, I got an idea to speed up the count of subnodes and leaves (expensive if only "lft" and "rgt" are used) by adding a third field called "lvl". See http://www.net-one.de/~ks/WOoK/postmaster.php http://www.net-one.de/~ks/WOoK/nset.sql.txt I wrote something about it here some months ago, got a few PMs with positive reactions (so I'm writing this) and a correction. Due to time lack, the 'documents' linked above are still draft, ugly written and the examples may work or not, sorry. The idea of "lvl" maybe useless or not? I'm not an expert. > So which model you use depends on what you intend to do with the tree. And try to understand Oleg's contrib/ltree. It may be better. Greetings, Knut Sübert