The CLEANUP utility physically erases logically deleted records from all or some areas in a database segment.
The CLEANUP utility physically erases logically deleted records from all or some areas in a database segment.
The CLEANUP utility works only with non-SQL-defined databases.
This article describes the following information:
You need this privilege
Clean up an area
The area
Clean up a segment
All areas within the segment
  ►►─── CLEANUP SEGMENT segment-name ───────────────────────────────────────────►  ►─── USING subschema-name ───────────────────────────────────────────────────►  ►─┬─────────────────────────┬────────────────────────────────────────────────►◄    │         ┌──────,──────┐ │    └─ AREA ──▼─ area-name ─┴─┘  
    Specifies the segment containing the areas to be processed.
  • segment-name
    The name of the segment.
    Specifies a subschema that describes all the sets, records, and areas that are related to the logically deleted records being processed.
  • subschema-name
    The name of the subschema.
  • AREA
    Specifies one or more areas within the segment to process.
    By default, if you do not specify any areas, all areas in the specified segment are processed.
  • area-name
    The name of an area within the specified segment.
How to submit the CLEANUP statement
You submit the CLEANUP statement by using either the batch command facility or the online command facility. The batch command facility can run in local mode or under central version.
How CLEANUP works
An area sweep is performed on each specified area. When a logically deleted record is found, each set in which the record is a member is processed. Every logically deleted record in the set is first disconnected and then physically erased. When all sets in which the original record was a member are processed, the sweep of the area is resumed.
When to use CLEANUP
Use the CLEANUP utility:
  • To erase deleted records in sets with no prior pointers
  • Before running the RESTRUCTURE utility
  • Before running the UNLOAD or RELOAD utilities
When not to use CLEANUP
Records in sets
prior pointers are erased when they are deleted. If all the sets in an area have prior pointers, you never need to use the CLEANUP utility.
You can use journaling while executing the CLEANUP utility to allow for recovery with the ROLLBACK utility.
LDEL counts
The number of logically deleted records (LDELs) reported in messages UT011020 and UT011021 reflect the number of LDELs encountered by the CLEANUP utility. Due to the architecture of how LDELs are removed, multiple LDELs might get removed for each one counted by the utility. To obtain an accurate count of the number of LDELs processed by the CLEANUP utility, a DBAN or PRINT SPACE report should be created for the requested area(s), both before and after the execution of the CLEANUP utility.
JCL Considerations
When you submit a CLEANUP statement through the batch command facility, the JCL to execute the facility must include statements to define:
  • The files containing the areas to be processed.
  • The journal files of the DMCL you are using. If you are not journaling, these should be dummied out.
For more information about the generic JCL used to execute the batch command facility, see the section for your operating system in this section.
The following example directs the CLEANUP utility to erase any logically deleted records in the EMP-DEMO-REGION area.
cleanup segment empdemo using empss01      area emp-demo-region;
Sample Output
When the CLEANUP operation is completed, the following listing is provided.
IDMSBCF                                              IDMS Batch Command Facility                            mm/dd/yy   PAGE 1    CLEANUP SEGMENT EMPDEMO USING EMPSS01               AREA EMPDEMO.EMP-DEMO-REGION;  UT000038 Starting CLEANUP of area EMPDEMO.EMP-DEMO-REGION  UT011020 CLEANUP completed.  Pages read=10  Records read=5  Ldel records read=2  UT011021 LDEL Record name BB  Found=2  Removed=2  Status = 0  AutoCommit will COMMIT transaction
For more information about preventing logically deleted records, see the
CA IDMS Database Administration Section