MainframeMaster

COBOL Tutorial

COBOL REORG-CRITERIA Clause - Quick Reference

Progress0 of 0 lessons

Overview

The REORG-CRITERIA clause is used to specify parameters for VSAM file reorganization operations. It controls how VSAM files are optimized during reorganization to improve performance and storage efficiency.

Purpose and Usage

  • VSAM optimization - Optimize VSAM file structure and performance
  • Space management - Control free space allocation and utilization
  • Performance tuning - Improve access patterns and I/O efficiency
  • Fragmentation reduction - Eliminate file fragmentation
  • Index optimization - Rebuild and optimize index structures

VSAM Reorganization Concept

Before: [Fragmented Data] [Poor Index] [Low Performance]
REORG-CRITERIA: [Optimization Parameters]
After: [Optimized Data] [Efficient Index] [High Performance]
Reorganization rebuilds file structure according to criteria

REORG-CRITERIA controls how VSAM files are rebuilt during reorganization.

Syntax

The REORG-CRITERIA clause follows specific syntax patterns for VSAM file reorganization and can include various optimization parameters.

Basic Syntax

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
* Basic REORG-CRITERIA clause syntax REORG-CRITERIA FREESPACE (data-percent, index-percent) RECORDSIZE (average, maximum) BLOCKSIZE (minimum, maximum) KEYLENGTH key-length INDEXED SEQUENTIAL * Complete example REORG-CRITERIA FREESPACE (20, 25) RECORDSIZE (100, 200) BLOCKSIZE (4096, 8192) KEYLENGTH 10 INDEXED * Alternative syntax for utility programs //REPRO EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * REPRO INFILE(INPUT.VSAM) OUTFILE(OUTPUT.VSAM) REORG-CRITERIA FREESPACE (15, 20) RECORDSIZE (80, 150) BLOCKSIZE (2048, 4096) /*

REORG-CRITERIA specifies optimization parameters for VSAM reorganization.

REORG-CRITERIA vs File Definition Comparison

AspectREORG-CRITERIAFile Definition
PurposeReorganization optimizationFile structure definition
UsageUtility programsApplication programs
File typeVSAM files onlyAll file types
TimingDuring reorganizationDuring file access
ImpactPerformance optimizationData access

Common REORG-CRITERIA Parameters

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
* FREESPACE parameter REORG-CRITERIA FREESPACE (data-percent, index-percent) * Example: 20% free space in data, 25% in index FREESPACE (20, 25) * RECORDSIZE parameter REORG-CRITERIA RECORDSIZE (average-size, maximum-size) * Example: Average 100 bytes, maximum 200 bytes RECORDSIZE (100, 200) * BLOCKSIZE parameter REORG-CRITERIA BLOCKSIZE (minimum-size, maximum-size) * Example: Minimum 2048, maximum 8192 bytes BLOCKSIZE (2048, 8192) * KEYLENGTH parameter REORG-CRITERIA KEYLENGTH key-length * Example: 10-byte keys KEYLENGTH 10 * File type indicators REORG-CRITERIA INDEXED * For KSDS files SEQUENTIAL * For ESDS files RELATIVE * For RRDS files

Different parameters control various aspects of VSAM reorganization.

Practical Examples

These examples demonstrate how to use the REORG-CRITERIA clause effectively in different VSAM reorganization scenarios.

Customer Master File Reorganization

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
* Customer master file reorganization //REORG1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * REPRO INFILE(CUSTOMER.MASTER) OUTFILE(CUSTOMER.NEW) REORG-CRITERIA FREESPACE (15, 20) RECORDSIZE (200, 250) BLOCKSIZE (4096, 8192) KEYLENGTH 10 INDEXED /* //REORG2 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DELETE CUSTOMER.MASTER RENAME CUSTOMER.NEW CUSTOMER.MASTER /* * Alternative using DFSMS utilities //REORG3 EXEC PGM=DFSMSTVS //SYSPRINT DD SYSOUT=* //SYSIN DD * REORG DATASET(CUSTOMER.MASTER) REORG-CRITERIA FREESPACE (15, 20) RECORDSIZE (200, 250) BLOCKSIZE (4096, 8192) KEYLENGTH 10 INDEXED END /*

REORG-CRITERIA optimizes customer master file for better performance.

Transaction File Optimization

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
* High-volume transaction file reorganization //TXNREORG EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * REPRO INFILE(TRANSACTION.FILE) OUTFILE(TRANSACTION.NEW) REORG-CRITERIA FREESPACE (10, 15) * Lower free space for high volume RECORDSIZE (150, 180) * Optimized for transaction records BLOCKSIZE (8192, 16384) * Larger blocks for better I/O KEYLENGTH 8 * Transaction ID length INDEXED /* //CLEANUP EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DELETE TRANSACTION.FILE RENAME TRANSACTION.NEW TRANSACTION.FILE /* * Performance monitoring after reorganization //PERFMON EXEC PGM=VSAMSTAT //SYSPRINT DD SYSOUT=* //SYSIN DD * STATS DATASET(TRANSACTION.FILE) REPORT PERFORMANCE /*

Transaction files benefit from optimized REORG-CRITERIA for high-volume processing.

Sequential File Reorganization

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
* ESDS (Entry Sequenced Data Set) reorganization //ESDSREORG EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * REPRO INFILE(LOG.FILE) OUTFILE(LOG.NEW) REORG-CRITERIA FREESPACE (5, 0) * Minimal free space for logs RECORDSIZE (80, 120) * Log record sizes BLOCKSIZE (2048, 4096) * Standard block sizes SEQUENTIAL * ESDS file type /* //SWAP EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DELETE LOG.FILE RENAME LOG.NEW LOG.FILE /* * Relative Record Data Set reorganization //RRDSREORG EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * REPRO INFILE(LOOKUP.TABLE) OUTFILE(LOOKUP.NEW) REORG-CRITERIA FREESPACE (20, 0) * Free space for future expansion RECORDSIZE (50, 50) * Fixed-size lookup records BLOCKSIZE (1024, 2048) * Small blocks for random access RELATIVE * RRDS file type /*

Different VSAM file types require different REORG-CRITERIA settings.

Performance Tuning Examples

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
* High-performance read-optimized file //READOPT EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * REPRO INFILE(REFERENCE.DATA) OUTFILE(REFERENCE.NEW) REORG-CRITERIA FREESPACE (5, 10) * Minimal free space for reads RECORDSIZE (300, 400) * Large reference records BLOCKSIZE (16384, 32768) * Large blocks for sequential reads KEYLENGTH 15 * Reference key length INDEXED /* * Write-optimized file with frequent inserts //WRITEOPT EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * REPRO INFILE(ACTIVE.DATA) OUTFILE(ACTIVE.NEW) REORG-CRITERIA FREESPACE (30, 35) * High free space for inserts RECORDSIZE (100, 150) * Variable transaction records BLOCKSIZE (4096, 8192) * Moderate block sizes KEYLENGTH 12 * Transaction key length INDEXED /* * Balanced performance for mixed workload //BALANCED EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * REPRO INFILE(GENERAL.DATA) OUTFILE(GENERAL.NEW) REORG-CRITERIA FREESPACE (20, 25) * Balanced free space RECORDSIZE (200, 250) * Typical record sizes BLOCKSIZE (8192, 16384) * Balanced block sizes KEYLENGTH 10 * Standard key length INDEXED /*

REORG-CRITERIA can be tuned for specific performance requirements.

Performance and Best Practices

Understanding performance implications and best practices ensures effective use of the REORG-CRITERIA clause.

Performance Considerations

  • FREESPACE impact - Higher values improve insert performance but reduce storage efficiency
  • BLOCKSIZE optimization - Larger blocks improve sequential access but may waste memory
  • RECORDSIZE accuracy - Accurate sizing improves space utilization and performance
  • KEYLENGTH optimization - Proper key length affects index performance
  • Reorganization frequency - Regular reorganization maintains optimal performance

Optimization Strategies

StrategyBenefitImplementation
Read optimizationFaster sequential accessLarge blocks, low free space
Write optimizationBetter insert performanceHigh free space, moderate blocks
Space efficiencyReduced storage usageLow free space, accurate sizing
Mixed workloadBalanced performanceModerate settings
High availabilityReduced reorganization needsConservative settings

Best Practices

  • Monitor file statistics - Track fragmentation and performance metrics
  • Schedule regular reorganization - Prevent performance degradation
  • Test reorganization settings - Verify performance improvements
  • Document criteria settings - Maintain configuration records
  • Consider workload patterns - Align settings with usage patterns
  • Plan for growth - Account for future data volume increases

Common Pitfalls to Avoid

PitfallProblemSolution
Excessive free spaceWasted storageBalance with usage patterns
Incorrect record sizesPoor space utilizationAnalyze actual record sizes
Inappropriate block sizesPoor I/O performanceMatch to access patterns
Infrequent reorganizationPerformance degradationSchedule regular reorganization
Ignoring workload changesSuboptimal performanceMonitor and adjust settings

REORG-CRITERIA Quick Reference

ParameterSyntaxPurpose
FREESPACEFREESPACE (data%, index%)Control free space allocation
RECORDSIZERECORDSIZE (avg, max)Specify record size parameters
BLOCKSIZEBLOCKSIZE (min, max)Define block size range
KEYLENGTHKEYLENGTH lengthSpecify key length
File typeINDEXED/SEQUENTIAL/RELATIVEIndicate VSAM file type

Test Your Knowledge

1. What is the primary purpose of the REORG-CRITERIA clause in COBOL?

  • To reorganize program structure
  • To specify VSAM file reorganization criteria
  • To reorganize data in memory
  • To reorganize JCL procedures

2. In which type of file operations is REORG-CRITERIA most commonly used?

  • Sequential files
  • VSAM files
  • Indexed files
  • Relative files

3. What happens during a VSAM reorganization operation?

  • Data is deleted and recreated
  • File structure is optimized and rebuilt
  • Records are sorted in a new order
  • File is copied to a new location

4. What is the relationship between REORG-CRITERIA and file performance?

  • No relationship
  • REORG-CRITERIA improves file performance
  • REORG-CRITERIA decreases file performance
  • REORG-CRITERIA only affects storage usage

5. Which of the following is a valid REORG-CRITERIA parameter?

  • FREESPACE
  • RECORDSIZE
  • BLOCKSIZE
  • All of the above

Frequently Asked Questions