from Hacker News

Show HN: Simple-graph – a graph database in SQLite

by dpapathanasiou on 12/26/20, 4:31 PM with 42 comments

  • by rklaehn on 12/26/20, 8:13 PM

    Interesting. SQLite is awesome.

    I did something similar recently, a block store for a rust implementation of ipfs, which models a directed acyclic graph of content-addressed nodes.

    https://github.com/actyx/ipfs-sqlite-block-store

    I found that performance is pretty decent if you do almost everything inside SQLite using WITH RECURSIVE.

    The documentation has some really great examples for WITH RECURSIVE. https://sqlite.org/lang_with.html

  • by rekwah on 12/26/20, 6:34 PM

    Tangentially related to graph dbs, but if you're looking for more hierarchical support, SQLite does has a transitive closure extension[0] that might be of some assistance. I leveraged this back in 2014 to write our framework-agnostic result storage on AWS Device Farm.

    [0] - https://www.sqlite.org/cgi/src/artifact/636024302cde41b2bf0c...

    [1] - https://charlesleifer.com/blog/querying-tree-structures-in-s...

  • by kevas on 12/26/20, 6:16 PM

  • by loxias on 12/27/20, 3:36 AM

    I really like this, OP. I'm member of the clan "why are you creating your own XDR, just use sqlite!!" and have oft jumped to that in technical discussions, so appreciate it.

    However, what's lacking from something like this is a detailed bill of the cost. I'd love to see some, any benchmark on a DB with > 10^6 edges to see how it goes. That's the other hand of the equation "just use sqlite and be happy" -- the expectation that performance will actually be reasonable.

  • by ptrik on 12/27/20, 1:43 AM

  • by bjornsing on 12/26/20, 5:50 PM

    How does this perform compared to a “native” graph database like Neo4J?
  • by lolive on 12/26/20, 6:56 PM

    I wonder if there are ways, in SQLite, to build indices for s,p,o/s,p/p,o/ and maybe more subtle ones... That would be uber nice, given the fact that most graph databases have their own indexing strategies, and you cannot craft your own.
  • by roland_nilsson on 12/27/20, 8:50 AM

    Isn't the whole point of graph databases that they can traverse graph edges efficiently by following pointers to nodes, which relational databases can't do? Then it seems a bit strange to implement a graph database on top of a relational database like SQLite?
  • by brian_herman on 12/26/20, 8:46 PM

    Awesome! And you can write SQL queries on the data amazing SQLite is the best database.