pvary commented on code in PR #19146: URL: https://github.com/apache/iceberg/pull/19146#discussion_r4698277194
########## site/docs/blog/posts/2026-11-11-converting-equality-deletes-to-deletion-vectors.md: ########## @@ -0,0 +1,235 @@ +--- +date: 2026-11-11 +title: "Cheap Writes, Fast Reads: Converting Equality Deletes to Deletion Vectors" +slug: flink-convert-equality-deletes-to-deletion-vectors +authors: + - mxm +categories: + - blog +--- + +<!-- + - Licensed to the Apache Software Foundation (ASF) under one or more + - contributor license agreements. See the NOTICE file distributed with + - this work for additional information regarding copyright ownership. + - The ASF licenses this file to You under the Apache License, Version 2.0 + - (the "License"); you may not use this file except in compliance with + - the License. You may obtain a copy of the License at + - + - http://www.apache.org/licenses/LICENSE-2.0 + - + - Unless required by applicable law or agreed to in writing, software + - distributed under the License is distributed on an "AS IS" BASIS, + - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + - See the License for the specific language governing permissions and + - limitations under the License. + --> + +Equality deletes allow low-latency row-level deletes in streaming applications, but they can greatly impact read performance. In a benchmark, we found that a full scan of a table after 1,000 upsert commits of 500 rows each takes about 23 seconds with equality deletes. The same table with the deletes converted to deletion vectors only takes about 1 second. + +When equality deletes were first introduced, they looked like an elegant solution for streaming writes with deletes because they defer the work of resolving deletes to the readers. Yet, their long term costs for readers were underestimated, which caused major pain to many Iceberg users. + +To solve this, we built `ConvertEqualityDeletes`, a Flink table maintenance task that converts equality deletes to deletion vectors in the background. The task can be used seamlessly with existing writers, without changing their existing write patterns. In table format v3, this enables converting equality deletes into deletion vectors which allows for efficient reads. For table format v4 and beyond, we believe that this work forms the basis for stopping to write equality deletes altogether. + +<!-- more --> + +## A short history of deletes + +In the v1 table spec, the only way to delete rows was to rewrite the data files that contain them (copy-on-write). The v2 spec added position deletes, which mark rows in existing data files as deleted without rewriting the files. The catch is that readers now have to skip the deleted rows (merge-on-read). The v3 spec replaced position delete files with deletion vectors, which store the deleted row positions of a data file as a compact bitmap. + +The v2 spec also added equality deletes for low-latency row-level deletes, typically found in streaming applications like change data capture (CDC). While a position delete marks a row as deleted, an equality delete only records the values of the row's equality columns, for example its primary key. + +## Two ways to delete a row + +Take a `users` table with the primary key `id`. A Flink job upserts the row with `id = 42`, which deletes the old version of the row and inserts the new one. The old version is row 17 of the data file `file-A`, and the new version goes to a new data file, `file-B`. Iceberg can store the delete in two ways: + +- An **equality delete** says "delete every row where `id = 42`". It identifies rows by value, so the writer only needs the key, which it already has. +- A **deletion vector** says "delete row 17 of `file-A`". It identifies rows by position, which the writer needs to keep track of. + +<figure markdown="span">{ width="750" }<figcaption>The same delete as an equality delete and as a deletion vector.</figcaption></figure> + +Semantically, both describe the same delete. However, equality deletes are cheap to write while producing deletion vectors require the writer to keep track of row positions across data files. On the other hand, equality deletes push the work to resolve the deletes to the readers while deletion vectors are an efficient format for the readers to perform merge-on-read. Review Comment: ```suggestion Semantically, both describe the same delete. However, equality deletes are cheap to write while producing deletion vectors requires the writer to keep track of row positions across data files. On the other hand, equality deletes push the work to resolve the deletes to the readers while deletion vectors are an efficient format for the readers to perform merge-on-read. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
