vlcn-io / cr-sqlite

Convergent, Replicated SQLite. Multi-writer and CRDT support for SQLite
https://vlcn.io
MIT License
2.77k stars 76 forks source link

Track db versions count #310

Closed jeromegn closed 1 year ago

jeromegn commented 1 year ago

Fixes #301

Creates a new table crsql_db_versions_total where the total number of changes per db version is tracked. This allows for our in-memory cache to be purged and therefore resources to be released.

It creates 1 extra trigger per insert/update/delete per crr-tracked table and 1 "global" trigger that cleans up the table when the total count of db versions reaches zero to keep it lean.

tantaman commented 1 year ago

all those merge commits 😅

I've cleaned up the history and opened a new pr with your changes -- https://github.com/vlcn-io/cr-sqlite/pull/313

jeromegn commented 1 year ago

I decided to use the clock tables directly in my queries in my program. This circumvents the performance regression explained in #313

Closing for now!