Re: Results of stored procedures in WHERE clause

From: "Justin Pasher" <justinp(at)newmediagateway(dot)com>
To: "'Gordon'" <gordon(dot)mcvey(at)ntlworld(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Results of stored procedures in WHERE clause
Date: 2008-05-22 23:06:17
Message-ID: MX13SOlbpH71yEXUIEA000001c6@mx1.ad.newmediagateway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
> owner(at)postgresql(dot)org] On Behalf Of Gordon
> Sent: Tuesday, May 20, 2008 11:03 AM
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] Results of stored procedures in WHERE clause
>
> I have a table representing tree structures of pages on a website.
> they have an itm_id column (integer key) and an itm_parent column
> (pointer to item's parent node). Any item with an itm_parent of 0 is
> a root node, representing a website. Anything with a non-zero parent
> is a non-root node representing a folder or document in a website.
>
> I need to be able to do queries that restrict my result set to items
> belonging to a specified site and ignore all nodes that belong to
> different sites. To determine the ID of the site an item belongs to I
> wrote a stored procedure:

...

I would highly recommend checking out the ltree contrib module. It will make
this task much easier, as long as you are not locked into the current
database design. Manually performing multi-level parent/child relationships
on a table can become quite painful. You will probably get faster results
using ltree also due to the fact that you can perform what you want with one
query instead of looping through multiple queries (very important if your
tree gets big).

http://www.sai.msu.su/~megera/postgres/gist/ltree/

Justin Pasher

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Howard Cole 2008-05-22 23:08:00 Error: Could not open relation...
Previous Message Adam Rich 2008-05-22 22:57:11 Re: Results of stored procedures in WHERE clause