Get the latest tech news
Representing Graphs in PostgreSQL
Some tricks and techniques for working with graph or tree like data in Postgresql
If we don’t mind building up arbitrarily long chains of CTEs, we can follow any number of edges using this technique. It would be kind of nice to be able to pass in the root node and the edge paths as parameters though, rather than dynamically building up the CTEs. This can then be parameterised, so we can create this as a prepared statement and call it lots of times with different root nodes and paths.
Or read this on Hacker News