Skip to content
Table Format Maintenance & Operations Last updated: May 29, 2026

Iceberg Spark Procedure rewrite_position_deletes

A Spark SQL maintenance procedure in Apache Iceberg used to consolidate small position delete files to improve query read times.

rewrite_position_deletes sparkcompact position deletesspark sql call rewrite_position_deletes

Iceberg Spark Procedure rewrite_position_deletes

The Iceberg Spark Procedure rewrite_position_deletes is a Spark SQL maintenance function designed to consolidate small, fragmented position delete files. In tables configured with the Merge-on-Read (MoR) strategy, row-level updates and deletes write small position delete files. Reading many small delete files at query time causes read amplification and slows down queries. This procedure merges them into larger files to optimize read-time merging.

Syntax and Implementation

The procedure is executed through the Spark SQL CALL syntax. It reads the small position delete files and rewrites them into larger, optimized files:

/* Consolidate position delete files for the target table */
CALL prod.system.rewrite_position_deletes(
    table => 'db.web_logs'
);

Performance Benefits

๐Ÿ“š Go Deeper on Apache Iceberg

Alex Merced has authored three hands-on books covering Apache Iceberg, the Agentic Lakehouse, and modern data architecture. Pick up a copy to master the full ecosystem.

โ† Back to Iceberg Knowledge Base