brodycj / ask-me-anything

ASK ME ANYTHING such as support, ideas, or personal questions
Creative Commons Attribution 4.0 International
4 stars 1 forks source link

Evaluating WAL for Cordova SQLite plugin solutions #7

Open brodycj opened 4 years ago

brodycj commented 4 years ago

For redesign of SQLite plugin for Apache Cordova (https://github.com/brodybits/ask-me-anything/issues/3), I would like to start evaluating whether or not to consider using WAL (https://www.sqlite.org/wal.html).

Use case: I think the primary benefit of WAL would be to alleviate possible blocking between writer(s) and readers, under the following kinds of circumstances:

Major drawbacks (as discussed in https://github.com/xpbrew/cordova-sqlite-storage/issues/643#issuecomment-285372916 and https://github.com/xpbrew/cordova-sqlite-storage-help/issues/10):

Major advantages of using WAL (from https://github.com/xpbrew/cordova-sqlite-storage-help/issues/10):

I discovered some more resources from: https://www.google.com/search?q=how+does+sqlite+checkpoint+work

At this point I think that using WAL should be optional and should come with some warnings.

brodycj commented 4 years ago

To keep the comparison as fair as possible, I would like to add that semantics of VACUUM (https://sqlite.org/lang_vacuum.html), where space for deleted data is not always cleaned up right away, seems to apply with and without WAL. But without WAL, SQLite would keep the deleted data pages in some kind of a "free list" where they could be used again. My understanding is that there are multiple forms of "auto vacuum", but a full "manual" vacuum would be better.

brodycj commented 4 years ago

Here are some interesting SQLite WAL+VACUUM links that I found: