Обсуждение: Common table expressions and threaded comments

Поиск
Список
Период
Сортировка

Common table expressions and threaded comments

От
Cultural Sublimation
Дата:
Greetings,

I need to implement the classical problem of threaded comments in a Postgresql
database.  I know that the upcoming 8.4 release includes Common Table
Expressions, so I have to ask: is this feature the mother-of-all-solutions
to the threaded comments problem, or is it still worth investigating ltree?

Also, lots of people mention Joe Celko's book on this subject.  Is it still
a valid resource, or do CTE's make it obsolete?

Thank you!
C.S.





Re: Common table expressions and threaded comments

От
Grzegorz Jaśkiewicz
Дата:
On Fri, Apr 17, 2009 at 1:40 PM, Cultural Sublimation
<cultural_sublimation@yahoo.com> wrote:
>
> Greetings,
>
> I need to implement the classical problem of threaded comments in a Postgresql
> database.  I know that the upcoming 8.4 release includes Common Table
> Expressions, so I have to ask: is this feature the mother-of-all-solutions
> to the threaded comments problem, or is it still worth investigating ltree?
>
> Also, lots of people mention Joe Celko's book on this subject.  Is it still
> a valid resource, or do CTE's make it obsolete?

Depending on what you actually need, but yes - CTE is the solution,
depending obviously on your schema design...

I think David (Fetter) had some examples in his slides on how to solve
common problems like that in a query.



--
GJ

Re: Common table expressions and threaded comments

От
Tom Lane
Дата:
Cultural Sublimation <cultural_sublimation@yahoo.com> writes:
> I need to implement the classical problem of threaded comments in a Postgresql
> database.  I know that the upcoming 8.4 release includes Common Table
> Expressions, so I have to ask: is this feature the mother-of-all-solutions
> to the threaded comments problem, or is it still worth investigating ltree?

I don't think you should take CTEs as being the be-all and end-all of
solutions in this area (or any other).  In particular I'd be suspicious
about the performance of a CTE-based solution.  CTEs are new in 8.4 and
we have done essentially zero optimization work on them.  I honestly
doubt if they will be able to match the performance of a single-purpose
solution such as ltree, even after a few years of optimization work.

            regards, tom lane

Re: Common table expressions and threaded comments

От
Grzegorz Jaśkiewicz
Дата:
I can only say for my own little experience. Features like that, allow
users to exchange less (none?) data between app and pg.
That's the main advantage of CTE.