sqlite-bank-space-diagnosis

Diagnose SQLite database and WAL file bloat using read-only space analysis and checkpoint quantification.

2|Updated Jul 18, 2026
One-click install
npx skills add https://github.com/Arasz/ai-badger --skill sqlite-bank-space-diagnosis-arasz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sqlite-bank-space-diagnosis
Source: https://github.com/Arasz/ai-badger/tree/main/features/common/skills/sqlite-bank-space-diagnosis
Command: npx skills add https://github.com/Arasz/ai-badger --skill sqlite-bank-space-diagnosis-arasz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? SQLite databases and their WAL files can grow to hundreds of megabytes without an obvious cause, especially under connection pooling where checkpoint truncation never fires. This Skill provides a measured, read-only-first workflow to find where the bytes actually live before attempting any fix. ## Core Features & Use Cases - Read-only diagnosis workflow: Snapshot the database with .backup, run sqlite3_analyzer for per-table space utilization, and check PRAGMA wal_checkpoint(TRUNCATE) on the snapshot to distinguish real checkpoint debt from already-checkpointed garbage. - WAL growth mechanics explained: Understand why passive auto-checkpoints cannot truncate while pooled connections hold read locks, causing unbounded WAL growth of already-checkpointed frames. - vec0 chunk storage trap: Avoid misreading vec0 chunk tables (one chunk row holds 1024 vectors) as an emptied index by validating with dbstat page counts and validity bitmaps. - Maintenance fix pattern: A BackgroundService pattern with startup/shutdown checkpoints, hourly TRUNCATE, and weekly VACUUM + ANALYZE that took a real bank from 461 MB to ~16-20 MB steady state. - Use Case: Your application's SQLite bank file shows a 431 MB WAL next to a 29 MB database. Use this Skill to prove the WAL is 100% reclaimable, truncate it in under a second, and design a bounded-footprint maintenance service. ## Quick Start Diagnose why my SQLite database file and its WAL are so large and tell me how much space I can safely reclaim.

Frequently Asked Questions about sqlite-bank-space-diagnosis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I diagnose why my SQLite database file is so large?

Snapshot the database with sqlite3 ".backup", then run sqlite3_analyzer on the snapshot for per-table freelist and payload efficiency. Quantify reclaimable space with VACUUM INTO on the snapshot, and stat the whole data directory including -wal and -shm files.

Why does my SQLite WAL file keep growing?

Passive auto-checkpoints sync content but cannot truncate the WAL while any pooled connection holds a read lock, so already-checkpointed frames accumulate unbounded. Run PRAGMA wal_checkpoint(TRUNCATE) and check the result row: 0|0|0 means the entire WAL is reclaimable garbage.

Does a read transaction block VACUUM in SQLite WAL mode?

No. In WAL mode readers and writers coexist, so a plain read transaction does not block VACUUM; only the single write lock does. To simulate VACUUM-busy in tests, hold BEGIN IMMEDIATE on another connection rather than a plain BEGIN with SELECT.

Why does my vec0 table show few rows but many pages?

vec0 stores vectors in chunk tables where one chunk row holds capacity for 1024 vectors, so count(*) counts chunks, not vectors. Verify with dbstat per-table page counts, rowid and length(vectors) capacity math, and the validity bitmap rows before concluding the index is empty.

What is the correct order for SQLite VACUUM, checkpoint, and ANALYZE?

VACUUM rewrites the file through the WAL, so checkpoint again after VACUUM, and run ANALYZE after VACUUM because VACUUM drops sqlite_stat1. Use VACUUM INTO on a snapshot first to quantify reclaim read-only before touching the live database.

What are the limitations of sqlite3_analyzer?

sqlite3_analyzer is a space-only tool: it reports freelist, payload efficiency, and overflow per table but has zero coverage of query performance, the WAL file, or FTS behavior. It cannot see a bloated WAL sitting next to the database file, so pair it with a checkpoint check.