Re: Summing & Grouping in a Hierarchical Structure

From: Don Parris <parrisdc(at)gmail(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Summing & Grouping in a Hierarchical Structure
Date: 2013-02-23 21:30:50
Message-ID: CAJ-7yomzgaohdJW5HhJ=c4FCQ389id4LWb-2Nye9dmwkT+Lk4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Misa & Ben,

Thanks. I guess I overlooked that in the docs. I did see the part about
the 65KB. I don't see my labels getting overly long. I'll be fine with
Herbs_Spices. I make up the labels myself, so it's really no big deal.

Alexander & Bryan - Many thanks for the help!

On Sat, Feb 23, 2013 at 3:13 PM, Ben Morrow <ben(at)morrow(dot)me(dot)uk> wrote:

> Quoth parrisdc(at)gmail(dot)com (Don Parris):
> >
> > Is it possible to use spaces in the ltree path, like so:
> > TOP.Groceries.Food.Herbs & Spices
> >
> > Or do the elements of the path have to use underscores and dashes?
>
> From the docs:
>
> | A label is a sequence of alphanumeric characters and underscores (for
> | example, in C locale the characters A-Za-z0-9_ are allowed). Labels
> | must be less than 256 bytes long. [...]
> |
> | A label path is a sequence of zero or more labels separated by dots,
> | for example L1.L2.L3, representing a path from the root of a
> | hierarchical tree to a particular node. The length of a label path
> | must be less than 65Kb, but keeping it under 2Kb is preferable.
>
> If you need to store non-alphanumeric labels, one answer (as long as
> they aren't too long) would be to use URL-encoding, like
>
> TOP.Groceries.Food.Herbs_20_26_20Spices
>
> Of course, you would need to encode _ as well, and you would need to be
> sure the labels weren't going to come out too long. Another alternative
> would be to MD5 each label and use (say) the first 10 bytes of that MD5
> in hex as the ltree label. (Annoyingly there's only one
> non-alphanumeric, so you can't use base64.) If you were going to do that
> you would need to consider the possibility of an attacker arranging a
> hash collision: I don't know where you're labels come from, so I don't
> know if this would be an issue.
>
> Ben
>
>

--
D.C. Parris, FMP, Linux+, ESL Certificate
Minister, Security/FM Coordinator, Free Software Advocate
http://dcparris.net/
<https://www.xing.com/profile/Don_Parris><http://www.linkedin.com/in/dcparris>
GPG Key ID: F5E179BE

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Don Parris 2013-02-24 22:20:32 Using Ltree For Hierarchical Structures
Previous Message Ben Morrow 2013-02-23 20:13:30 Re: Summing & Grouping in a Hierarchical Structure