Repository navigation
Conversation
MayCXC
force-pushed
the
delete-empty-chunk-photostructure
branch
from
October 23, 2026 03:33
247a80e to
f323788
Compare
This was referenced Oct 23, 2026
Closed
… and text keys DELETE already zeroes the deleted row's rowid and vector slots (b632185), and test-delete-clears-bytes.py checks that for a float vector. These tests from asg017/sqlite-vec@cb147c8 check it for int8 and bit vectors and for a table with a text primary key.
A chunk whose rows were all deleted stayed in _chunks, _vector_chunksNN, and _metadatachunksNN until optimize removed it. DELETE now deletes those rows once it clears the chunk's last validity bit. Ported from asg017/sqlite-vec@cb147c8 via vlasky/sqlite-vec@3a64182, whose _rowid_ part ef903ed already ported. Upstream also finalizes stmtLatestChunk there; that statement reads max(rowid) afresh each time it runs, so this port leaves it. The upstream tests come with it, and the delete-completeness fuzz target again checks DELETE alone. test-optimize-reclaims-space.py now deletes every other row, so optimize still has chunks to compact, and the interrupt test deletes the last row of a chunk.
MayCXC
force-pushed
the
delete-empty-chunk-photostructure
branch
from
October 23, 2026 17:03
f323788 to
825a449
Compare
This was referenced Oct 23, 2026
mceachen
added a commit
that referenced
this pull request
Oct 24, 2026
…validity handle #7 reopened and reread the chunk's validity blob after every DELETE to find out whether the chunk was now empty, which made DELETE 12-15% slower. vec0Update_Delete_ClearValidity() now reads the bitmap through the handle it already holds, and only once the cleared byte is zero.
Member
|
Landed as 52a818d and b08c04b, thanks. Follow-up 4a8ffe0: every DELETE reopened and reread the chunk's validity blob to check whether the chunk was empty, which made DELETE 12–15% slower on a 100,000-row table. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two commits that finish porting asg017#268 (asg017@cb147c8). This fork already has its zeroing (b632185) and its
_rowid_binding (ef903ed, from vlasky@3a64182); what it lacks is the chunk deletion. asg017 and vlasky both have it, so this PR has no twins.Deleting the emptied chunk. A chunk whose rows are all deleted stays in
_chunks,_vector_chunksNN, and_metadatachunksNNuntiloptimizeremoves it:vec0Update_Delete_DeleteChunkIfEmpty()deletes those rows once a DELETE clears the chunk's last validity bit, as cb147c8 and vlasky/sqlite-vec@3a64182 do, with three differences:vec0_error_rc(), as the rest of the delete path does, so an interrupted DELETE still fails withSQLITE_INTERRUPT. With upstream's plainSQLITE_ERROR, the newdelete-emptying-chunkcase oftest_interrupt_is_reported_as_interruptfails.stmtLatestChunk. That statement isSELECT max(rowid) FROM _chunks, reset after every use, so it reads the current maximum each time without being prepared again.bitmap_any()and drops upstream'sdeletedout-parameter, which no caller reads.Tests:
test_legacy_insert_after_chunk_deletednow empties its chunk with DELETE alone, without theoptimizecall. It still fails withError opening vector blobwhen ef903ed's_rowid_binding is taken out.test_optimize_reclaims_pages_with_autovacuum_incrementaldeletes every other row instead of the upper half. Deleting the upper half now empties two chunks, which DELETE removes beforeoptimizeruns, sooptimizewould have nothing left to compact; with every other row deleted it still compacts four partly empty chunks into two. vlasky's port kept the upper-half delete and changed the expected count after the delete, so itsoptimizeassertion no longer testsoptimize.DELETE FROM v, as upstream's does, without theoptimizecall this fork added to it. Built from main, the target fails itsv_chunksassertion on the first corpus input that inserts a row. A 60-second run of this branch, as the fuzz workflow does, found nothing in 10,502 inputs.delete-emptying-chunkcase intest_interrupt_is_reported_as_interruptdeletes the last row of a chunk, so the interrupt test reaches the three new statements.Zeroing tests. The first commit adds cb147c8's delete tests for int8 and bit vectors and for a text primary key, which check the zeroing b632185 does. They pass on main.
Rebased onto main at a791836.
make test-loadable(466 passed, 3 skipped) andmake test-unitpass, and so does the Python suite against an AddressSanitizer and UndefinedBehaviorSanitizer build. The build has no warnings. One-at-a-time deletes took as long as on main, measured on f793711: deleting every other row of a 50,000-row table took 0.25 to 0.27 s against 0.24 to 0.29 s, and deleting every row took 0.49 to 0.64 s against 0.48 to 0.65 s.