Hacker News new | ask | show | jobs
by nickstefan12 3029 days ago
Our app models directed graphs in Postgres with a closure table (the transitive edges between nodes).

The advantages are that it's just sql, has good performance, and we can query the graph using relational logic rather than n+1 traversal. The trade off is space (the closure table has the potential to be huge).

So it depends on the size of the data set. Part of me wishes we'd built something that's easier to partition, but for now that's a future concern.

1 comments

Surely another disadvantage of storing all that redundant data is that either (a) you lose atomicity of updates or (b) have some terrifyingly large transactions for a relatively simple change to the underlying data.

Whether this is acceptable depends not only in the size of the data set but also how often it changes compared to how often you query it.