aergoio / litetree

SQLite with Branches
MIT License
1.62k stars 35 forks source link

Does PRAGMA branch_truncate() deletes the "future" or the "past"? #8

Closed skunkiferous closed 5 years ago

skunkiferous commented 6 years ago

At first look, I thought this would be great for "game saves", but one thing is not clear to me: how to prevent the DB from growing infinitely.

Keeping the entire transaction history of a DB, which is the only way one can implement "branching from a previous transaction", has a significant cost.

Is "PRAGMA branch_truncate()" used to truncate the "history of the past", thereby "compacting" it, or is it there to remove all changes after some point, thereby performing a "revert"?

If "PRAGMA branch_truncate()" is used to "revert" a branch to a previous state, then how do you "merge all changes" before some point, thereby loosing the history, to compact the database? Without it, the DB will grow infinitely, even if you only ever modify one single row in one single table.

kroggen commented 6 years ago

Hi!

The branch_truncate function deletes the commits at the end (future).

And the database grows. It has some space reuse but not that much. It is the price we pay.

It is interesting to have a way to merge commits. This is not possible at this version.

I will add this to the wishlist.

kroggen commented 6 years ago

Good news:

A truncation at the start of the history may be possible up to where the first child branch starts.

Although the implementation may take a while due to the new features list.

skunkiferous commented 6 years ago

This is great news. Once implemented, I'm sure you could get more users from the gaming devs, if you advertise it as a solution for 'incremental' game saves.

kroggen commented 5 years ago

Hi!

The support for discarding old commits is available in the discard-commits branch.

If you find any bug, please report it as a new issue.