Questions tagged [recursive]

Using recursion to solve database problems.

Filter by
Sorted by
Tagged with
2 votes
1 answer

How do I query a table with many trees of data, for one tree?

I have a the NAICS schema loaded and all is working well. However I'm confused as how I'd query it in Postgrseql? The table looks something like this, =========NAICS_2012========= naics | ...
Evan Carroll's user avatar
  • 62.1k
8 votes
1 answer

Recursive CTE performance

Need help with recursive CTE performance. Below CTE is running very slow as it is trying to pull heirarchical data recusively. Table is big with every root id having upto 3 recursive itemid. There ...
njvds's user avatar
  • 101
33 votes
2 answers

Using EXCEPT in a recursive common table expression

Why does the following query return infinite rows? I would have expected the EXCEPT clause to terminate the recursion.. with cte as ( select * from ( values(1),(2),(3),(4),(5) ) ...
Tom Hunter's user avatar
  • 2,159

1 2 3 4 5