About connectby() again

From: Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: About connectby() again
Date: 2002-09-26 17:02:49
Message-ID: 20020927020159.216C.RK73@sea.plala.or.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 07 Sep 2002 10:21:21 -0700
Joe Conway <mail(at)joeconway(dot)com> wrote:

> I just sent in a patch using the ancestor check method. It turned out
> that the performance hit was pretty small on a moderate sized tree.
>
> My test case was a 220000 record bill-of-material table. The tree built
> was 9 levels deep with about 3800 nodes. The performance hit was only
> about 1%.

The previous patch fixed an infinite recursion bug in
contrib/tablefunc/tablefunc.c:connectby. But, other unmanageable error
seems to occur even if a table has commonplace tree data(see below).

I would think the patch, ancestor check, should be

if (strstr(branch_delim || branchstr->data || branch_delim,
branch_delim || current_key || branch_delim))

This is my image, not a real code. However, if branchstr->data includes
branch_delim, my image will not be perfect.

-- test connectby with int based hierarchy
DROP TABLE connectby_tree;
CREATE TABLE connectby_tree(keyid int, parent_keyid int);

INSERT INTO connectby_tree VALUES(11,NULL);
INSERT INTO connectby_tree VALUES(10,11);
INSERT INTO connectby_tree VALUES(111,11);
INSERT INTO connectby_tree VALUES(1,111);

SELECT * FROM connectby('connectby_tree', 'keyid', 'parent_keyid', '11', 0, '-')
AS t(keyid int, parent_keyid int, level int, branch text)

ERROR: infinite recursion detected

Regards,
Masaru Sugawara

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Doug cNaught 2002-09-26 17:16:36 Re: [HACKERS] Performance while loading data and indexing
Previous Message Bruce Momjian 2002-09-26 16:41:34 Re: Performance while loading data and indexing