Using spark maintenance procedures, deleteOrphanFiles & expireSnapshotShots taking many hours for a small iceberg table
Query engine
Spark 3.2.3
Question
I am running expireSnapshots and delteOrphanFiles after compaction from spark maintenance procedures. this job is taking many hours to finish for small table of size 5 GB & 4000 files.
Is there a better way/options to run these procedures faster.
do you know which step is taking up most time?
If it is the planning phase there isn't much to do since most of the cost is in reading the manifests. With 4000 files there are most likely many many manifests. You can try increasing the size of the manifest reading thread pool to increase parallelism there but it's best to just optimize manfiests more regularly and take the cost for one long optimize to start with. I would also highly recommend running optimize data files more frequently as well if you have 4000 files that only take up 5 gb.
If it's in the delete phase you just need to enable bulk deletes, this is default in newer versions of Iceberg. In older versions of Iceberg there was an explicit delete parallelism parameter for expire snapshots and delete orphan files. If you are on an older version set these parameters to a high number like 50 or 100. If delete are taking a long time it's probably latency of getting the delete response which is taking so long.
Thanks russell, i have enabled parallel deletes and it improved the performance.