[GENERAL] recursive query?

2004-02-02 Thread CSN
I have a table with these columns: id, node, parent_node_id The top-most nodes would have a parent_node_id of NULL. Is it possible to get a node, and all its parent nodes, in a single query? For example, a node might be: books > computers > databases > oss > postgres and the rows fetched would

Re: [GENERAL] recursive query?

2004-02-02 Thread Andrew Rawnsley
Couple of ways to do it. One is to use the hierarchical query patch that mimics Oracle's CONNECT BY syntax at http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp? recipe_id=19490. Another way is to use a nested set model, described at http://www.geocrawler.com/archives/3/6/2001/

[GENERAL] recursive query returning extra rows in 8.4

2013-10-14 Thread Chris
Hi all, Using postgres 8.4.13 (latest that redhat provides in rhel6) the query below returns an extra row compared to running the same thing in later versions (tried 9.0, 9.1, 9.2 - they don't return the extra row). Just wondering if anyone had thoughts on why, and/or how to remove the dupli

Re: [GENERAL] recursive query returning extra rows in 8.4

2013-10-15 Thread David Johnston
chris smith-9 wrote > Hi all, > > Using postgres 8.4.13 (latest that redhat provides in rhel6) the query > below returns an extra row compared to running the same thing in later > versions (tried 9.0, 9.1, 9.2 - they don't return the extra row). > > > SELECT * > FROM numbers > ORDER BY iterati

Re: [GENERAL] recursive query returning extra rows in 8.4

2013-10-15 Thread Tom Lane
David Johnston writes: > chris smith-9 wrote >> Using postgres 8.4.13 (latest that redhat provides in rhel6) the query >> below returns an extra row compared to running the same thing in later >> versions (tried 9.0, 9.1, 9.2 - they don't return the extra row). > Likely this is a bug that was f

Re: [GENERAL] recursive query returning extra rows in 8.4

2013-10-15 Thread Chris
On 16/10/13 01:56, Tom Lane wrote: David Johnston writes: chris smith-9 wrote Using postgres 8.4.13 (latest that redhat provides in rhel6) the query below returns an extra row compared to running the same thing in later versions (tried 9.0, 9.1, 9.2 - they don't return the extra row). Likel

[GENERAL] recursive query too big to complete. are there any strategies to limit/partition?

2017-01-26 Thread Jonathan Vanasco
There are over 20 million records in a self-referential database table, where one record may point to another record as a descendant. Because of a bug in application code, there was no limit on recursion. The max was supposed to be 4. A few outlier records have between 5 and 5000 descendants

Re: [GENERAL] recursive query too big to complete. are there any strategies to limit/partition?

2017-01-26 Thread David G. Johnston
On Thu, Jan 26, 2017 at 4:37 PM, Jonathan Vanasco wrote: > There are over 20 million records in a self-referential database table, > where one record may point to another record as a descendant. > > Because of a bug in application code, there was no limit on recursion. > The max was supposed to b

Re: [GENERAL] recursive query too big to complete. are there any strategies to limit/partition?

2017-01-26 Thread Jonathan Vanasco
On Jan 26, 2017, at 7:07 PM, David G. Johnston wrote: > ​Thinking aloud - why doesn't just finding every record with 5 descendants > not work? Any chain longer than 5 would have at least 5 items. Oh it works. This is why I ask these questions -- new perspectives! > ​Even without recursion you