Re: Chain/Thread Problem

From: "J Sensel" <"jsensel ateggheadsdotcom"(at)news(dot)hub(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Chain/Thread Problem
Date: 2003-05-16 16:53:08
Message-ID: SYadnZo2kN4VilijXTWcrg@giganews.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Sammy..

A quick and dirty approach is something like this:

id|threadid|emailid|referenceid|pathlevel
---------------------------------------
1|t101|e323|null|0
2|t101|e545|e323|1
3|t101|e822|e545|2
4|t101|e999|e323|1
etc..

Do the sorting when you insert the records. Then they can be quickly &
easily retrieved. Otherwise you're looking at a recursive query. Not very
efficient. This way is crude but allows the engine to optimize queries with
indexes.

HTH

Jim

"Sammy" <sammynash(at)uboot(dot)com> wrote in message
news:6729af8d(dot)0305160646(dot)d9ab2d2(at)posting(dot)google(dot)com(dot)(dot)(dot)
> Hi,
>
> I have a SQL problem for you all. What SQL qurey would I have to make
> on the following table to extract the chain (thread) of emails in a
> conversation.
>
>
> id|emailid|referenceid
> -----------------------
> 1| e125 | Null (Start of chain)
> 2| r1fe | e125 (2nd letter in chain)
> ...
> ...
> n| e4ju | r1fe (3rd in chain)
>
> ie
> a sucessulf qurey would return rows 1,2 & n because they are all in
> the chain.
>
> Hope you can help me with my problem,

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2003-05-16 17:22:37 Re: Chain/Thread Problem
Previous Message Matt Mello 2003-05-16 16:08:11 Re: "deadlock detected" documentation