Re: recursing down a tree
От | Jeff Davis |
---|---|
Тема | Re: recursing down a tree |
Дата | |
Msg-id | 200207040322.32773.list-pgsql-general@empires.org обсуждение исходный текст |
Ответ на | Re: recursing down a tree (Fran Fabrizio <ffabrizio@mmrd.com>) |
Ответы |
Re: recursing down a tree
|
Список | pgsql-general |
I did a little research on the subject and it seemed quite interesting. However, it seemed that insertion would require updating most of the tree for a minor insert. Can you send along a few more details about your setup and algorithms? I would like to find more information about this. Regards, Jeff On Tuesday 02 July 2002 06:07 am, Fran Fabrizio wrote: > Carl Meyer wrote: > >hi, > > > >say i have a table with something like > > > >id,parent,description > > Depending on what your most common types of queries are, you might be > better off with Joe Celko's nested set model (from the book SQL for > Smarties). It would do: > > id, left, right, description > > where you traverse the tree depth-first and as you pass the left side of > each node you increment a counter (left) and as you pass by it again on > the right you increment it again (right). > > This model provides much easier ways of making queries such as "give me > all descendants of id=2" because there's then no recursion (WHERE > child.left between parent.left and parent.right). > > I had a table set up exactly as you have described, and when the > recursion proved too costly in terms of db performance, I went to nested > set and we're pleased with the results. > > Just another option, > Fran > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster
В списке pgsql-general по дате отправления: