Best practice for mass cleanup of Pega Repository / File Storage

@VincenzoF1238
I agree you’re heading in the right direction. The first step is to identify the attachments that need to be deleted.

You can retrieve the attachment metadata and repository path from Data‑WorkAttach‑File. Persist the key identifiers (such as attachment key, work object key, repository reference, and file path) into a separate data type/table dedicated to deletion tracking.

Once the attachments are identified:

  • Store only the required key parameters in this data table

  • Create appropriate indexes to support efficient querying and batch processing

Storing even millions of records is not a concern, since the table will contain only lightweight metadata and keys.

Using this table as a control list, you can then execute a controlled, batch‑based deletion process to remove the corresponding files from the repository ensuring proper tracking, retry handling, and auditability.