Updated on 2026-06-27 GMT+08:00

Clearing Outdated Paimon Data

Scenarios

Clearing outdated data can free up storage space, optimize resource utilization, and improve system performance.

Expiring Snapshots

Snapshots are used to restore historical data. During their retention period, the associated historical data files cannot be deleted. As snapshots are continuously generated, storage space usage keeps increasing. By clearing snapshot files that are no longer needed, you can free up the space occupied by the historical data files they reference.

The parameters listed in Table 1 determine the expiration time of snapshot files.

Table 1 Parameters controlling snapshot expiration

Parameter

Description

Data Type

Default Value

snapshot.num-retained.min

The minimum number of completed snapshots to retain

Integer

10

snapshot.num-retained.max

The maximum number of completed snapshots to retain

Integer

2147483647

snapshot.time-retained

The maximum time of completed snapshots to retain

Duration

1h

If the current number of snapshots exceeds snapshot.num-retained.min, snapshot expiration is triggered when the snapshot count exceeds snapshot.num-retained.max or when the age of the earliest snapshot exceeds snapshot.time-retained.

Manually Deleting Temporary Files

Due to job errors or restarts, some uncommitted temporary files may remain in the Paimon table directory. These files cannot be deleted through the snapshot expiration mechanism and must be manually deleted. You can run the following SQL statement to clean the files:

CALL my_catalog.sys.remove_orphan_files(table => '<my_db>.<my_table>');

In the preceding statement, my_catalog indicates the Paimon catalog name, my_db indicates the name of the database where the Paimon table to be cleared is located, and my_table indicates the name of the Paimon table to be cleared. This operation deletes only obsolete files older than 1 day by default. You can pass additional parameters to specify the cleanup deadline. However, ensure that all write tasks started before the specified time have completed. For example, if a write task can run for a maximum of 2 hours, the cleanup deadline must be set to at least 2 hours before the current time. Otherwise, data files generated by running but uncommitted tasks may be deleted accidentally, causing data loss. For example, to delete obsolete files created on or before 2026-01-01 12:00:00 from the my_catalog.my_db.my_table table, run the following statement:

CALL my_catalog.sys.remove_orphan_files(table => '<my_db>.<my_table>', older_than => '2026-01-01 12:00:00');