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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Graphs

Graphs

Photo of PostgreSQL

PostgreSQL

Related news:

News photo

Memory profilers, call graphs, exception reports, and telemetry

News photo

Scaling with PostgreSQL without boiling the ocean

News photo

A Rust procedural language handler for PostgreSQL