Delete & compact
Remove records with delete, reclaim their space with compact, and commit the result to disk with save.
Removing data from Telys is two steps. delete(ids) drops rows from the live set so they stop appearing in searches and listings; compact() reclaims the space those deleted and superseded rows held. Finish with save() to write the result to disk.
Delete records — delete(ids)
delete(ids) removes only the IDs that are currently present. Missing IDs are ignored, so a delete is safe to retry and never raises for a missing ID.
from telys import Telys
telys = Telys("./telys-data")
col = telys.open_collection("notes") # no embedder needed to delete
before = len(col)
col.delete(["note-3", "note-9"])
after = len(col)
print(before, "->", after)After a delete the IDs are gone from the live set:
"note-3" in col # -> False
col.ids(where=None) # no longer lists note-3 or note-9Deleting an ID that is not present is a no-op:
Compact — compact()
Deletes and updates are versioned: a removed or replaced row is soft-deleted rather than erased, so the on-disk footprint does not shrink immediately. compact() rewrites the collection to drop those dead rows and reclaim their space.
Compaction leaves the live set unchanged — len(col) and ids() are the same before and after; only storage shrinks. Run it after a batch of deletes or updates, not after every mutation. See Versioning, soft-delete & compaction for the full model.
Commit — save()
delete and compact change the in-memory state; save() writes it to disk and is the commit point.
Expected result
A delete lowers the live count and drops the IDs from listings; compaction reclaims space without changing the count; save() persists it all:
Next steps
Last updated
Was this helpful?