Milvus Storage–Compute Separation, Part 4: The Pain of Deletes
Why deletes cost more than inserts
For most databases, deletes are more expensive and harder to implement than inserts for two reasons.
- A delete must first establish whether its target exists, so it implicitly requires at least one lookup.
- A delete changes historical data. It therefore requires random writes or removals. Beyond the holes such operations can leave in storage, random access itself can cost more than sequential access by over two orders of magnitude.
Those properties impose extra design constraints on any database.
Why the problem is sharper in Milvus
The problem is amplified in a storage–compute-separated vector database such as Milvus.
- Deleting a node from a vector index is expensive enough that in-place updates are not acceptable.
- A delete has a large distribution scope. A Milvus segment is produced by a DataNode, stored in object storage, and used by a QueryNode. A delete must therefore be visible across the compute-node group rather than in just one folder or bucket. If a segment that could contain the target does not receive the delete, data that should be invisible can still appear in search results.
The local mechanism: a delete mask
Milvus preserves the immutability of a vector index by making deleted vectors invisible through a bitset mask. In the illustration below, node 2 has a delete-mask bit of 1. Index traversal skips that node as a candidate result, while its links to other nodes remain usable as traversal edges.
The distributed data flow
Like inserts, deletes are written to both storage and compute. On a DataNode, a delete is persisted as delta logs and uploaded to object storage. On a QueryNode, a delegator forwards the delete to every segment that may contain the relevant data. Each compute node creates the corresponding delete mask, and queries use that mask to preserve delete visibility.
Why deletes are broadcast
It is tempting to store a delete mask only in the delegator and remove deleted rows only after the delegator merges results. That would avoid the write amplification of broadcasting deletes.
It can preserve correctness in the narrow sense that returned rows are not deleted, but it cannot guarantee that the client receives a full top-K result. Suppose a client asks for top 2 and three segments each return their local top 2. If the centralized delete mask marks 1, 2, 3, 4, and 8 as deleted, merging and filtering can leave only primary key 5. Broadcasting the mask to every segment avoids that shortfall because each segment can continue searching past its locally deleted candidates.
The remaining question: delete ordering
The preceding discussion considers deletes under static conditions. In a system with real-time updates, it is not enough to establish that data has been deleted; the system must also define when that deletion becomes visible. That ordering problem deserves its own treatment.
Takeaway
Storage–compute separation makes delete design a distributed consistency problem as well as a local index problem. Milvus addresses it with immutable indexes, per-segment delete masks, and propagation to every segment that may hold the deleted data.
— MrPresent-Han



