Skip to content

chore(db): enable auto-vacuum and add periodic maintenance#31528

Open
BYK wants to merge 1 commit into
anomalyco:devfrom
BYK:chore/db-auto-vacuum
Open

chore(db): enable auto-vacuum and add periodic maintenance#31528
BYK wants to merge 1 commit into
anomalyco:devfrom
BYK:chore/db-auto-vacuum

Conversation

@BYK

@BYK BYK commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #31526

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Enables SQLite incremental auto-vacuum and adds maintenance utilities:

  1. One-time migration: detects auto_vacuum = 0 (NONE) and switches to INCREMENTAL. Runs a full VACUUM to apply the mode change. Subsequent database opens skip this since the mode persists.

  2. checkpoint(): runs PRAGMA wal_checkpoint(TRUNCATE) to flush the WAL file and reclaim disk space.

  3. vacuum(): runs PRAGMA incremental_vacuum to reclaim free pages from deleted rows.

These can be called periodically (e.g., on session idle) to keep database size in check.

Re-filing of #23053 which was auto-closed by the cleanup bot.

How did you verify your code works?

Tested locally by checking PRAGMA auto_vacuum before and after the migration. Verified the one-time VACUUM runs on first open and is skipped on subsequent opens. Tested checkpoint() and vacuum() functions directly.

Screenshots / recordings

N/A — database maintenance improvement.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

One-time migration: detect auto_vacuum = 0 (NONE) and switch to
INCREMENTAL. Run a full VACUUM to apply the mode change. Subsequent
database opens skip this since the mode persists.

This prevents the database file from growing indefinitely as deleted
rows leave behind free pages that are never reclaimed.
@BYK BYK force-pushed the chore/db-auto-vacuum branch from 8982e1a to d36ebf7 Compare June 9, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite auto_vacuum is disabled, database files grow indefinitely

1 participant