Hacker News new | ask | show | jobs
by abetlen 2062 days ago
While you can use recursive common table expressions to perform graph queries, certain queries like breadth-first traversal are not very efficient for anything but trees (not even DAGs). See my post on the sqlite forum from the other day for more details

https://sqlite.org/forum/forumpost/cd5ff0a1d4?t=h

1 comments

IMHO fixing this is more a job for the query planner/optimizer than for the SQL language itself. I wonder if there's a more general optimization that would help with this and other similar graph-related tasks...
It isn't a query planner/optimizer problem.

Generalized graph traversals require each query to have additional data structures that grow with table size. This becomes an expensive proposition as tables get large, especially if you have many concurrent queries. Some databases designed for graph processing have internals and storage models that make it more efficient to resource manage this extra state. A SQL database, which has other priorities, would not implement this.