pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Schmeder <andy@qabobala.xapnet.com>
To: Ron Peterson <rpeterson@yellowbank.com>
Cc: pgsql-general@postgresql.org
Subject: Re: recursive queries?
Date: Mon, 10 Apr 2000 06:48:20 -0700
Message-ID: <00041006553405.00353@qabobala> (raw)
In-Reply-To: <38F0AEEC.C322276A@yellowbank.com>
References: <38F0AEEC.C322276A@yellowbank.com>

> Personally, I'm really only interested in something elegant.  Meaning I
> don't want to mess around with a solution where this broker communicates
> with that broker via an n-way blah blah blah.  I can maintain literacy
> in several tools at once, but not several dozen.  Is my best bet simply
> to accept SQL's limitations and program around them in C++ (or C, or
> Python, or Perl, etc.)?

Good question!  I have certainly given this one some thought before.  One of my
projects involved a directory structure of sorts which allowed non-cyclic
symlinking.  My solution in this case was to create a seperate table that was a
'map' -- the map was a pre-calculated, flattened version of the entire graph. 
Thus, a single query of the map table for "/blah/blah2/etc/" returned
immediately correct subdirectory.  Each time the linking tables are updated,
the map table must be re-calculated.  This solution will not work for the
general cyclic graph, of course...  and it may be inappropriate for the
situation where the link tables are update frequently since each update forces
a large recursive caluculation of the map -- the primary advantage is the speed
and easy of querying.  

I am not aware of any SQL constructs of 'for' loops or 'while' loops, so I am
not sure how one could solve the problem in pure SQL -- actually, you probably
could using a recursive stored procedure.


Andy



view thread (27+ messages)  latest in thread

Message-ID: <00041006553405.00353@qabobala>
Permalink:  ../00041006553405.00353@qabobala/
Also on:    postgresql.org/message-id/00041006553405.00353@qabobala

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: andy@qabobala.xapnet.com, rpeterson@yellowbank.com
  Subject: Re: recursive queries?
  In-Reply-To: <00041006553405.00353@qabobala>
  References: <38F0AEEC.C322276A@yellowbank.com> <00041006553405.00353@qabobala>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox