-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: introducing sqlite as a datastore #605
Comments
cc @yusefnapora, as discussed today during the call with @Warchant and @kamilsa (cpp-libp2p). |
@Stebalien pretty sure you have thoughts about this? |
+1 I am very fond of sqlite. |
A drawback is the logistics around Cgo compilation :-( |
My concerns with sqlite are:
Ideally we'd have some kind of pure-go solution available. My concerns with anything not "datastore" is flexibility:
In terms of performance:
All that aside, we feel the pain in go-ipfs and an actual database would make quite a few things quite a bit simpler. It also looks like there's a pretty reasonable SQL abstraction for golang (https://golang.org/pkg/database/sql/). TL;DR: Let's do it as long as we abstract over any SQL database. In go-ipfs, my primary motivation is that it makes pinning, GC, graph traversal, reverse graph traversal, etc. much easier. Really, we need a graph database but SQL is probably the best general-purpose solution. |
I'm definitely in favor, for all the reasons described above. @vyzo - just like old times! sqlite for metadata indices + rocksdb for blob storage worked really well for mediachain. |
To store clearly defined entities I would recommend repository pattern: (below is a pseudocode):
Implementation(s) of this interface may use SQLite, postgres, or even multiple KV stores.
From my experience, it is very hard to define clear and generic interface for SQL/KV storages and Repository works well every time. |
@Warchant definitely something to consider! Abstracting away how we store entities vs. abstracting how we generically access a database. The former allows us to use database-specific optimisations and indexing – something the latter struggles to enable. |
Some of our use cases become excruciating to implement efficiently with KV stores:
The lack of indices hurts us badly. We are penalised by protobuf serde on every query and iteration. Ad-hoc GC logic has sprouted across various modules. I'm not confident KV stores award us the flexibility to support future use cases.
Should we start an experiment to explore adopting sqlite as our main datastore? We can define together what our evaluation, scoring and success criteria should be.
I doubt we'll need an abstraction layer analogous to go-datastore, because the other two alternatives (Apache Derby and H2) are JVM-based, so no chance to use those as a backend anyway.
go stdlib already supports sql, and if we want to get fancy, we can evaluate squirrel for SQL generation. I discourage ORMs.
The text was updated successfully, but these errors were encountered: