Reproduced and quantified on a 1.89 GB production database (V2, 0.0.0-beta-17498): 3,246 sessions,
114,870 session_message rows. I ran this on a copy, so the deletions below are real, not modelled.
Baseline — the freelist looks harmless right up until you delete something
page_size 4096
page_count 462,233 → 1,893,306,368 bytes
freelist_count 1,085 → 4.4 MB, 0.23% of the file
auto_vacuum 0 (NONE)
Almost all of it is live data, not slack — session_message alone is 1.678 GB of the 1.893 GB
(105,379 assistant rows averaging 13.7 KB each). On a never-deleted instance this issue is invisible,
which I suspect is why it has stayed open: nothing looks wrong until the first bulk delete.
Deleting half the sessions strands 855 MB that never comes back
session_message cascades from session_v2 (ON DELETE CASCADE), so deleting sessions removes their
messages. Deleting 1,623 of 3,246 sessions dropped 51,849 message rows:
page_count freelist_count file size
before 462,233 1,085 1,893,306,368
after delete 462,233 208,655 1,893,306,368
Not one byte returned to the filesystem, and 855 MB — 45% of the file — became free pages. That is
exactly the behaviour described in the report.
VACUUM does recover it: 1,893,306,368 → 1,005,211,648 bytes, 888 MB reclaimed, 46.9%, in 11.3 s
wall on this database.
The migration detail that will bite whoever implements this
PRAGMA auto_vacuum = INCREMENTAL is a no-op on an existing database. Measured on the same snapshot:
PRAGMA auto_vacuum=INCREMENTAL; PRAGMA auto_vacuum; → 0 (unchanged)
PRAGMA auto_vacuum=INCREMENTAL; VACUUM; PRAGMA auto_vacuum; → 2 (INCREMENTAL)
The mode only changes when a full VACUUM rewrites the file, so setting the pragma at connection open
fixes new databases and silently does nothing for every existing one. Shipping this needs a one-time
migration VACUUM — 11.3 s here, and it needs a progress signal or it will look like a hang on
startup (compare #38561, #35514, #41739).
Once the mode is actually INCREMENTAL, reclamation no longer needs a full rebuild:
after delete (INCREMENTAL) freelist 200,272 file 1,828,679,680
after PRAGMA incremental_vacuum freelist 0 file 1,007,357,952
821 MB returned without a rewrite. That is the vacuum() utility the issue asks for, and it is cheap
enough to run on a schedule.
One correction to the thread
@skywalker-35's 36 GB case is attributed to part.data accumulating tool output. That was V1's
layout. On this V2 instance part is a migration leftover: its newest row is dated 2026-07-03 while
session_message is current to today, and no V2 code path writes it. It sits at 128 MB against
session_message's 1.678 GB. Same failure, different table — a retention policy aimed at part would
now miss almost all of the bytes.
Note that auto_vacuum addresses only reclamation after deletion. It does nothing about growth itself —
1.89 GB from 3,246 sessions with nothing deleted is a separate question about assistant-message
payload retention.