Re: Recursive Arrays 101

From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Recursive Arrays 101
Date: 2015-11-05 11:56:19
Message-ID: 563B43E3.5080201@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/11/2015 17:53, Rob Sargent wrote:
> On 11/04/2015 03:03 AM, Achilleas Mantzios wrote:
>> Sorry for being kind of late to the party (I was in 2015.PgConf.EU !!), and not having read
>> most of the replies, what we have been successfully doing for this problem for our app
>> is do it this way :
>> parents int[] -- where parents stores the path from the node to the root of the tree
>> and then have those indexes :
>> btree (first(parents))
>> btree (level(parents)) -- length
>> btree (last(parents))
>> gin (parents gin__int_ops) -- the most important
>>
>> This has been described as "genealogical tree" approach, and works very good, IMHO much better
>> than nested sets.
>>
> Is there a more complete description of this approach available? By the title one might assume could be applied to populations as opposed to phylogeny (the OP's use case). Does it deal with
> consanguinity? Does it perform well going "up" the tree (which is of course branched at every level)?

From here https://en.wikipedia.org/wiki/Phylogenetic_tree I assume that phylogenetic trees are normal
trees, and I see no reason why not be modeled with the genealogical approach described. The earliest paper
I based my work on was :
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CCUQFjABahUKEwiR6auUlvnIAhXGvhQKHVyDA-s&url=https%3A%2F%2Fdownload.samba.org%2Fpub%2Funpacked%2Fldb%2Fldb_sqlite3%2Ftrees.ps&usg=AFQjCNEktJsibP435MBki5cdGmO_CzKmwg&sig2=I9yC_tpyeWrEueDJTXbyAA&bvm=bv.106674449,d.d24&cad=rja

Finding the root is O(1). Going "up" the tree or finding common ancestry is reduced to the problem
of finding overlap/intersections/contains/contained between postgresql arrays.

The indexes, functions and operators provided by contrib/intarray were a basic element for the success of this
approach.

--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2015-11-05 15:33:41 Re: Recursive Arrays 101
Previous Message Victor Blomqvist 2015-11-05 07:19:37 Re: Drop or alter column under load give ERROR #42804 structure of query does not match function result type: