TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

LiteTree: SQLite with Branches

343 pointsby kroggenover 6 years ago

22 comments

diego_moitaover 6 years ago
Fossil[1] is a SCM system (like git) created by the very same author of SQLite (D. Richard Hipp). It uses SQLite as its database and implements versioning and branching[2] and even merging (which LiteTree doesn&#x27;t do) on its own, by recording the changes on each item on a separate table.<p>This approach is more complex to implement but a lot more versatile and flexible. Most of times you wouldn&#x27;t want to version or branch the whole database, but only parts of it.<p>[1] <a href="https:&#x2F;&#x2F;www.fossil-scm.org" rel="nofollow">https:&#x2F;&#x2F;www.fossil-scm.org</a><p>[2] <a href="https:&#x2F;&#x2F;www.fossil-scm.org&#x2F;index.html&#x2F;doc&#x2F;trunk&#x2F;www&#x2F;branching.wiki" rel="nofollow">https:&#x2F;&#x2F;www.fossil-scm.org&#x2F;index.html&#x2F;doc&#x2F;trunk&#x2F;www&#x2F;branchin...</a>
评论 #17869235 未加载
nneonneoover 6 years ago
Thanks for posting this. My first thought was - has this been sent through the official SQLite battery of tests? If so, have the tests been adapted to validate branches, rapid branch switches, branching under failure conditions (malloc fails, power outages, etc) and concurrent access patterns?<p>One of the reasons why SQLite is so widely used is that it is carefully tested and shown to be reliable even in potentially faulty conditions. As detailed on <a href="https:&#x2F;&#x2F;sqlite.org&#x2F;testing.html" rel="nofollow">https:&#x2F;&#x2F;sqlite.org&#x2F;testing.html</a>, there are three test sets, one of which is public (the TCL set). I’d love to see test results to assure the safety of any data stored in LiteTree.
评论 #17866714 未加载
beardicusover 6 years ago
&gt; LiteTree is more than TWICE AS FAST than normal SQLite on Linux and MacOSX!!!<p>In my experience, claims like these usually end up showing that the author didn&#x27;t understand the `PRAGMA synchronous` setting at all, or they chose to ignore it to juice their stats.<p>In this benchmarking test are the data durability guarantees the same for both LiteTree and vanilla SQLite?
评论 #17868111 未加载
评论 #17870552 未加载
评论 #17867557 未加载
cannadayrover 6 years ago
Neat. I&#x27;ll have to compare this to my own implementation.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;cannadayr&#x2F;git-sqlite" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cannadayr&#x2F;git-sqlite</a><p>Instead of storing the transactions as a separate lmdb commit, I decided to store the database in a git repository and expose the diffs using sqlite&#x27;s sqldiff utility. This allowed my workflow to be almost unchanged and limits the dependencies to git, sqlite, sqldiff, &amp; bash.
评论 #17866163 未加载
DocSavageover 6 years ago
There has been earlier work on getting git-style branched versioning on top of databases. For relational databases, OrpheusDB (<a href="http:&#x2F;&#x2F;orpheus-db.github.io&#x2F;" rel="nofollow">http:&#x2F;&#x2F;orpheus-db.github.io&#x2F;</a>) puts a layer over PostgreSQL. They also supply a gRPC layer for interacting with the server.<p>For key-value systems, there are simple techniques for adding branched versioning to key-value (particularly ordered key-value) stores. We are using it for our research dataservice that holds 25+ TB of Connectomics data, which includes 3d image and segmentation data (<a href="http:&#x2F;&#x2F;dvid.io" rel="nofollow">http:&#x2F;&#x2F;dvid.io</a>). Our paper is currently under review but should have been out several years ago :) We can use a variety of key-value storage backends and are experimenting with versioned relational DBs, so I&#x27;ll definitely give LiteTree a look.
评论 #17868489 未加载
rubyfanover 6 years ago
Can anyone elaborate a use case for something like this? I’m guessing there’s some blockchain connection but it’s not immediately obvious
评论 #17867326 未加载
评论 #17867844 未加载
评论 #17868467 未加载
natmakaover 6 years ago
Is the function similar to PostgreSQL&#x27;s deprecated &quot;Time Travel&quot; <a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;6.3&#x2F;static&#x2F;c0503.htm" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;6.3&#x2F;static&#x2F;c0503.htm</a> ?<p>AFAIK this can be a foundation for some form of Snapshot Isolation <a href="https:&#x2F;&#x2F;www.sqliteconcepts.org&#x2F;SI_index.html" rel="nofollow">https:&#x2F;&#x2F;www.sqliteconcepts.org&#x2F;SI_index.html</a> (?)
评论 #17866125 未加载
transfireover 6 years ago
If merge gets supported than it could serve as an alternative for program development -- using tables to store function definitions, constants, etc. instead of using flat files.
评论 #17867004 未加载
评论 #17866499 未加载
aureboxover 6 years ago
I am looking for exactly for this kind of implementation for my work project - having a DB using version control model.<p>However I need a production ready solution.<p>There is also: <a href="https:&#x2F;&#x2F;github.com&#x2F;attic-labs&#x2F;noms" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;attic-labs&#x2F;noms</a> But the project does not seem mature enough.<p>Do you know if there is any way to achieve this with an aim for production? What would be the best way&#x2F;stack to get this result with current available tools?
评论 #17866684 未加载
2T1Qka0rEiProver 6 years ago
I&#x27;m looking at this will little knowledge of how this makes the blockchain application easier. What seems odd to me is that merging branches isn&#x27;t supported? So you can&#x27;t perform a bunch of &quot;transactions&quot; and then merge them back into your master state. Maybe someone could illuminate the purpose this solves a little more clearly, as I&#x27;m guessing it has <i>nothing</i> to do with my naive understanding.
评论 #17867792 未加载
评论 #17870050 未加载
评论 #17867311 未加载
tripueover 6 years ago
Interesting project. How do you achieve theses performances ?
评论 #17866073 未加载
andridkover 6 years ago
Very interesting stuff!<p>Is it possible to see a history of a column, table, schema, etc? Is it possible to tag a certain point in time?<p>It would be liberating for many schema designs that we could just change stuff and be sure that the database knew what was changed and when with the ability to roll changes back.
mingodadover 6 years ago
Looking at the README it&#x27;s not clear how indexes are managed. Like when we create a branch and add some data to an existing table and move back to a previous branch and try to add data with the same index keys ?
评论 #17866792 未加载
nathancahillover 6 years ago
Interesting, I implemented something similar a long time ago, have to see if I can dig up the source code. The goal was to support forking data without duplicating unchanged data.
评论 #17866809 未加载
masa331over 6 years ago
This looks great. Thank you for creating it and sharing it
amiroucheover 6 years ago
Why did you choose LMDB among leveldb, wiredtiger and bsddb or even gdbm?<p>It seems like you do not rely on range queries at all.
评论 #17873124 未加载
geordeeover 6 years ago
Interesting. The branches could solve the &quot;date-effective&quot; table designs. In the past I had used Git as a database to store multiple versions of a document efficiently.<p>Or this could be used as some elementary partitioning logic where each branch is effectively a partition.
srikuover 6 years ago
The use case seems to overlap with noms dB - <a href="https:&#x2F;&#x2F;github.com&#x2F;attic-labs&#x2F;noms" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;attic-labs&#x2F;noms</a><p>Noms doesn&#x27;t have the appeal of SQL, but it is versioned and forkable and strongly typed data.
评论 #17869402 未加载
chaz6over 6 years ago
This is interesting and I hope I can find a use case for it. However, the performance compared to vanilla SQLite makes me anxious that there is a trade-off elsewhere, such as crash integrity.
评论 #17866758 未加载
amiroucheover 6 years ago
&gt; LiteTree is implemented storing the SQLite db pages on LMDB.<p>Why are you doing it like that? Does it lead to some limitation of some sort? Like making merge very costly?
评论 #17873218 未加载
boksioraover 6 years ago
great stuff :) this is innovation :)
coleiferover 6 years ago
Cool project thanks for sharing your work. There&#x27;s an older project using lmdb (which doesn&#x27;t support branching or anything, just for storage)...is litetree&#x27;s usage of lmdb comparable to what sqlightning does? How does litetree work with the write-ahead log? How do multiple concurrent connections interact? Are multiple writers allowed? Can readers and writer(s) coexist?
评论 #17873310 未加载