Re: usage for 'with recursive'?

From: Kenneth Downs <ken(at)secdat(dot)com>
To: hubert depesz lubaczewski <depesz(at)gmail(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: usage for 'with recursive'?
Date: 2007-03-01 13:13:05
Message-ID: 45E6D161.7040805@secdat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hubert depesz lubaczewski wrote:
> there have been a discussions about how posdtgresql needs 'with
> recursive' queries.
>
> not that i would like to object the idea (new feature is always a
> good thing), but is anybody able to show me real usage of this kind of
> queries?
> as i see it the only usage for 'with recursive' is when one have a
> tree-structure stored as:
> create table objects (id serial primary key, parent_id int references
> objects (id), ...)
> and one want to do some "deep queries" without client-side
> recursion/loops.
>
> is it the only thing 'with recursive' is useful for? i mean it sounds
> unrealistic given that better data-structures for tree hierarchies
> have been proposed and implemented.

Better? I think perhaps different. There is materialized path, which
requires a very problematic unlimited-length column to hold the path,
and there is upper/lower bounds, which again requires client-side
row-by-row processing. Both have the unpleasant problem that changes to
one row may affect many others.

AFAIK, the "WITH RECURSE" allows the simplest data structure, being
key/parent_key. The best benefit of this method is that it is a simple
foreign key and no action on a row ever affects another row, unlike the
other two. If we could query out a list using WITH RECURSE it would
become very powerful.

>
> best regards,
>
> depesz
>

--
Kenneth Downs
Secure Data Software, Inc.
www.secdat.com / www.andromeda-project.org
Office: 631-689-7200 Cell: 631-379-0010

::Think you may have a problem with programming? Ask yourself this
::question: do you worry about how to throw away a garbage can?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Willy-Bas Loos 2007-03-01 13:15:49 cast bytea to text
Previous Message Isak Hansen 2007-03-01 12:52:58 Re: Assistance with Query Optimisation?