Skip to main content

Delete modes: deletion vectors against equality deletes

The Iceberg sink removes a row's old version in one of two ways (sink.deleteMode): an equality delete on the primary key, cheap to write and applied by every reader until a compaction, or a deletion vector (positional), which marks the old row's position and so has to find it first. This page records what each costs on the write side and on the read side, measured with the benchmark harness (issue #750).

What was run​

Eight runs: both modes over four table layouts. One table (events, composite key (tenant_id, event_id), 64 tenants), 200,000 seeded rows, an 8-minute live window at a mean of 300 mutations/s in transactions of up to 200 rows, 15% inserts, 75% updates, 10% deletes, payloads up to 1 KiB, one worker, no maintenance. The configurations are in test/e2e/pods/bench/delete-mode/.

layoutpartitioningupdates
unpartitionednoneuniform over the table
bucketbucket(16, event_id)uniform
tenantidentity(tenant_id)uniform
tenant, hotidentity(tenant_id)90% on 4 of the 64 tenants

Environment: Urutau at 0223d42 (production image), one minikube node (16 CPU, 46 GiB) with MySQL 8.4.11, RustFS, Polaris and Trino 483 on the same node. The numbers compare the modes on this node; they are not a characterization of Urutau at scale. Another project's Pods ran on the node during some of the runs.

Write side​

layoutmodeconvergedend-to-end latency p50 / p99worker commitsmean commitdata files read per commit (mean / max)worker memory, max
unpartitionedequalityyes, 33 s after the window4.1 s / 5.7 s2530.39 s—142 MiB
unpartitionedpositionalyes, 55 s21.2 s / 46.7 s1583.11 s78 / 156133 MiB
bucketequalityyes, 69 s10.2 s / 20.1 s2491.02 s—73 MiB
bucketpositionalyes, 724 s336 s / 688 s6617.7 s494 / 941188 MiB
tenantequalityyes, 103 s21.4 s / 51.4 s1612.94 s—159 MiB
tenantpositionalno (15-minute settle)368 s / 1,096 s for what did arrive; 8,150 transactions never visible3387 s and growing958 / 1,979257 MiB
tenant, hotequalityyes, 80 s22.7 s / 43.6 s1503.32 s—100 MiB
tenant, hotpositionalno574 s / 1,135 s for what did arrive; 10,424 never visible20180 s and growing415 / 972226 MiB

What the numbers say:

  • A positional commit reads every data file of the table. The mean of files read per commit is half the final file count in every layout: each commit read all the files that existed. The scan plan's filter is the range of the batch's first key column, and a batch of uniform updates spans the whole range. Concentrating the updates on four tenants changed nothing: the other 10% still span every tenant.
  • Partitioning multiplies the cost. Every commit adds a data file per partition it touches, so the file count grows 16 or 64 times faster, and the next commit reads them all. Unpartitioned, a positional commit costs 8 times an equality one and the pipeline keeps up. With 16 buckets it costs 17 times and the sink runs minutes behind. With 64 tenant partitions the commits take minutes and the pipeline does not catch up.
  • The time is spent waiting on the object store, not computing. The positional worker used at most 0.55 CPU; the files are read one after another.
  • Memory is not the constraint. The positional worker stayed under 260 MiB.

Read side​

A full scan through Trino (SELECT count(*), sum(rev)), median of three, once the run had settled; then ALTER TABLE … EXECUTE optimize, and the same scan again.

layoutmodedata / delete files beforescan beforecompactiondata / delete files afterscan after
unpartitionedequality252 / 2521.40 s8.4 s1 / 10.10 s
unpartitionedpositional157 / 1520.70 s6.8 s1 / 00.12 s
bucketequality3,942 / 3,9538.19 s19.1 s16 / 160.18 s
bucketpositional957 / 8711.04 s6.7 s16 / 00.18 s
tenantequality8,696 / 8,75512.16 s18.8 s64 / 650.20 s
tenant, hotequality7,477 / 7,5698.97 s15.8 s64 / 200.19 s

The two positional runs on the tenant layout did not converge and were not scanned.

  • Before a compaction, the positional tables scan 2 to 8 times faster. Part of that is fewer files: the positional runs made fewer, larger commits because each one took longer, so the two sides do not hold the same number of files.
  • After a compaction the modes are indistinguishable.

After #864​

The write-side numbers above were taken at 0223d42. They showed where a positional commit's time went, and three changes followed (#864): the plan filter covers every key column and lists up to 200 distinct values one by one, so a small batch reads only the partitions and files its keys can be in; the candidate data files are read sixteen at a time; and the deletion vectors a commit replaces are read one Puffin file at a time instead of one vector at a time. That last one was the larger cost: a commit replacing 1,573 vectors spent 36 s decoding the same few Puffin footers.

The four positional runs again, same configurations, at ddd3cc4:

layoutconvergedend-to-end latency p50 / p99mean commit (before)data files read per commit (mean / max)worker memory, maxscan before compaction
unpartitionedyes, 30 s after the window3.9 s / 10.4 s1.42 s (3.11 s)122 / 243157 MiB0.99 s
bucketyes, 80 s57.9 s / 83.7 s4.0 s (17.7 s)773 / 1,760252 MiB1.29 s
tenantyes, 172 s66.6 s / 141 s7.36 s (87 s, growing)1,314 / 3,679287 MiB2.59 s
tenant, hotyes, 229 s86.8 s / 237 s7.22 s (180 s, growing)1,355 / 3,972274 MiB2.80 s

Every layout now converges with Iceberg equal to MySQL. Unpartitioned, the end-to-end latency matches equality mode (3.9 s against 4.1 s) at 3.6 times its commit cost. Partitioned, a positional commit still costs 2.5 to 4 times an equality one and the sink runs about a minute behind under this load, where equality runs 10 to 20 s behind.

What did not change: a batch of thousands of keys spread over the table still has every data file as a candidate. The files read per commit are still half the final file count; they are only read faster. The cost of a positional commit stays proportional to the number of data files, which is what a compaction bounds and what the index of #754 would remove.

With the deletes already applied by position, the scan before a compaction takes 1.0 to 2.8 s on tables where equality deletes take 1.4 to 12.2 s.

Recommendations​

A persistent key → position index (#754). The condition for opening it is met by the first set of numbers, and the scan has since been made as cheap as a scan gets (#864): pruned by every key column, read concurrently. What remains is structural. A positional commit of a batch spread over the table reads the key columns of every data file, so its cost grows with the file count: 1.4 s at 240 files, 7 s at 3,700. Maintenance compacting the table bounds that; the index removes it. Whether the index is worth building depends on how far behind a partitioned table may run: about a minute under this load without it.

bucket(N, pk) as a table layout. Not on these numbers. A batch of thousands of uniformly spread keys touches every bucket, so bucketing prunes nothing and multiplies the data files: the bucketed table committed in 4.0 s where the unpartitioned one took 1.4 s.

Positional deletes as the default (#755). Not yet. On an unpartitioned table the mode now keeps the latency of equality deletes and scans faster before a compaction, at 3.6 times the commit cost. On a partitioned table it runs a minute behind. Equality stays the default; the positional mode stays opt-in and experimental.