Repository navigation
A deployment can ask for superseded chunks to give up their vector after a set number of days, so a re-pushed base stops carrying every past version in its index - #1492
Conversation
…hing cites is removed, so a re-pushed base stops carrying every past version in its index Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
…a document restored from the trash is still found by meaning Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
WaylandYang
left a comment
There was a problem hiding this comment.
Thanks for the numbers in #1481, and sorry it waited without an answer. The problem is real for a large 3072-dim base. We'd like a narrower shape:
- Vectors only. Drop the embedding of an old superseded chunk, but keep the row. History stays readable for as-of replay and the deletion can't lose anything we can't recompute.
- Opt-in. Off by default; a deployment turns it on and sets the window. The default behaviour for every other deployment stays as it is.
- Record it. Revise ADR 0019 for the retention choice, and update the comment in `replace_chunks` (documents.rs, "向量留着"), which now argues the opposite of the code.
- Clamp `days` to a sane range: 0 or less currently prunes every superseded chunk, and a huge value panics in `Duration::days`.
If you measured that the HNSW index actually shrinks after the prune (or needs a REINDEX), please note it in the ADR.
…tor, so a deployment that does not ask keeps its history searchable and one that does keeps every row Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
|
Thank you, and no need to apologise. The narrower shape is better, and it is in 381eafc.
I have not measured the HNSW index after a prune yet, so the note says that plainly and describes what I expect, space reused after VACUUM and a smaller file only after a REINDEX. I will post the real numbers from our large base once it has run there. The title and description are updated to match. |
|
I looked at our large base for the index numbers. They are real, but they are not the clean before and after you asked for, so I would rather say exactly what they are.
Two caveats.
What the numbers do show is the other half. The TOAST relation is still 8.5 GB for about 1 GB of vectors, so the space a cleared vector frees is reused and not given back. That matches the note in the ADR. If you would like it, I can put these numbers into the ADR note in place of "not yet measured". |
WaylandYang
left a comment
There was a problem hiding this comment.
Thanks, this is the shape we wanted. On the numbers: since they come from the earlier row-delete shape and a rebuilt index, I'd keep them in this thread rather than the ADR; the note as written is accurate. Optional follow-up: making chunks_superseded_idx partial on superseded_at IS NOT NULL AND embedding IS NOT NULL would let cleared rows leave the index, so the daily sweep doesn't rescan all history. Merging.
Sync upstream dev into re-dev (2026-11-16): deeplethe#1489, deeplethe#1492 and 11 more
For #1481.
A deployment can now ask for a superseded chunk to give up its vector after a number of days. It is off by default, so every existing deployment keeps what it has today. Setting
UTOPIA_SUPERSEDED_VECTOR_DAYSturns on a dailyprune_supersededjob per base, which clears the vector of a chunk superseded longer ago than that window. Only the vector goes. The row, its text and everything that points at it stay, so version replay and chunk fetch at anyas_ofread as before, and the vector can be computed again from the text.The window is clamped to 1 to 3650 days, so zero or a negative number cannot clear everything and a huge one cannot overflow. A deleted document's chunks are left whole, so a restore brings it back searchable by meaning.
What a deployment that opts in gives up is vector recall of a replaced paragraph at an
as_offurther back than its window. ADR 0019 has a dated note for this, and the comment inreplace_chunksnow says the same thing as the code.On the HNSW index, I have not measured it yet and the ADR note says so. pgvector does not index a NULL vector, so a cleared chunk leaves the graph once VACUUM removes the dead tuple and that space is reused. I expect the file itself to shrink only after a REINDEX. I will post the real numbers from our large base once it has run there.
Migration 0126 adds a partial index on
(kb_id, superseded_at)so the daily pass reads only superseded chunks.Tests:
an_old_version_keeps_no_vector(the row stays and the vector goes, a trashed document is untouched) and theretention::windowunit tests for the clamp.