Skip to content
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

AUTO-VACUUM or not? #646

Open
brodycj opened this issue Mar 9, 2017 · 2 comments
Open

AUTO-VACUUM or not? #646

brodycj opened this issue Mar 9, 2017 · 2 comments

Comments

@brodycj
Copy link
Contributor

brodycj commented Mar 9, 2017

Unfortunately the DRAFT https://www.w3.org/TR/webdatabase/ does not explicitly deal with manual VACUUM vs AUTO-VACUUM. The following sections may be relevant:

https://www.w3.org/TR/webdatabase/#sensitivity-of-data:

[...] user agents should ensure that when deleting data, it is promptly deleted from the underlying storage.

https://www.w3.org/TR/webdatabase/#disk-space:

User agents should limit the total amount of space allowed for databases.

I found the following resources from a quick search:

The following resources describe the various AUTO-VACUUM options:

I would personally favor FULL AUTO-VACUUM since it seems to avoid indeterminate interruptions and (along with #645: secure delete) keep things cleaned up in general.

Another idea would be to make this an openDatabase option.

@brodycj
Copy link
Contributor Author

brodycj commented May 9, 2017

In many cases JavaScript app authors do not consider memory & disk resource management at the earliest prototyping & delivery stages. I would highly favor enabling auto-vacuum by default in the next major (if not minor) release to deal with these cases.

An excellent resource about auto-vacuum on Android: http://stackoverflow.com/questions/25135463/where-we-need-use-vacuum

According to http://www.sqlite.org/pragma.html#pragma_auto_vacuum there are some tricks needed to enable auto-vacuum on existing sqlite database files.

An alternative may be to make this more explicit by introducing a mandatory setting in the next major release.

@brodycj
Copy link
Contributor Author

brodycj commented Dec 13, 2017

From http://www.sqlite.org/pragma.html#pragma_auto_vacuum with bold emphasis added to a few relevant items:

The default setting for auto-vacuum is 0 or "none", unless the SQLITE_DEFAULT_AUTOVACUUM compile-time option is used. The "none" setting means that auto-vacuum is disabled. When auto-vacuum is disabled and data is deleted data from a database, the database file remains the same size. Unused database file pages are added to a "freelist" and reused for subsequent inserts. So no database file space is lost. However, the database file does not shrink. In this mode the VACUUM command can be used to rebuild the entire database file and thus reclaim unused disk space.

So if no form of VACUUM or AUTO-VACUUM is used:

  • no disk space will be lost since disk space for deleted data will be used to store new data
  • database file will never shrink

I hope to document this sometime later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant