Re: Sorting with materialized paths

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ovid <curtis_ovid_poe(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Sorting with materialized paths
Date: 2010-05-10 18:06:33
Message-ID: i2h407d949e1005101106hf18cbea6wffdd9ce1d73700e9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, May 9, 2010 at 4:47 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Ovid <curtis_ovid_poe(at)yahoo(dot)com> writes:
>> My apologies. This isn't PG-specific, but since this is running on PostgreSQL 8.4, maybe there are specific features which might help.
>> I have a tree structure in a table and it uses materialized paths to allow me to find children quickly. However, I also need to sort the results depth-first, as one would expect with threaded forum replies.
>
> I think contrib/ltree might help you here.  However, it seems to sort
> node names textually rather than numerically, so you might need to
> change it a bit for your own purposes.
>

That's rather unfortunate. Ltree is awfully convenient and it would be
nice to be able to use it.

If you just used plain Postgres arrays of integers you would get the
sorting you want. But you lose all the useful ltree operators for
trees.

--
greg

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2010-05-10 18:59:11 Re: How to do pg_dump + pg_restore within Perl script?
Previous Message Peter Hunsberger 2010-05-10 17:55:31 Re: Sorting with materialized paths