Db2 for z/OS space management connects logical database design to physical storage. Tables and indexes look like catalog objects to SQL, but their pages live in VSAM linear data sets that must be allocated, extended, monitored, reorganized, and protected from hard capacity limits. This tutorial explains how to size those objects, choose growth controls, reserve useful free space, use compression, interpret extents, and handle production growth without treating one DDL value as a permanent answer.
Space management has three time horizons. At design time, the DBA chooses table-space type, page size, partitioning, DSSIZE, maximum partitions, storage group, and initial allocation policy. During normal operation, Db2 consumes free pages and extends data sets as rows and index entries arrive. During maintenance, utilities reclaim fragmented space, rebuild compression dictionaries, redistribute free space, materialize pending changes, and produce the statistics needed for the next forecast.
The goal is not to minimize every allocated byte. A space with no headroom can fail during a burst; a space with badly placed free room can suffer page splits or relocated rows; and a space with generous but unused allocations can waste scarce volumes. Good management balances availability, performance, recovery time, utility windows, and storage cost. It also distinguishes allocated space from used pages and from the theoretical object maximum.
Db2 page sets are defined as VSAM linear data sets. The buffer-pool page size determines the logical page size for a table space, while VSAM control intervals provide the transfer and allocation structure underneath. Db2-managed data sets are created and extended according to the object definition, storage-group policy, SMS classes, and available volumes. A partitioned table space normally has a distinct data set for each partition; sufficiently large nonpartitioned structures can use multiple pieces.
This boundary explains why a Db2 symptom can have a storage-system cause. Db2 asks to extend a data set, but media manager, VSAM, SMS, the catalog, and physical volumes participate in satisfying the request. An extension can fail because no eligible volume has room, a data set reached DSSIZE, a partition-by-growth space reached MAXPARTITIONS, or an extent-related limit was reached. Always preserve the accompanying z/OS and DSNP messages instead of diagnosing from an SQLCODE alone.
123456789101112131415Logical object Physical allocation ------------------------------ ----------------------------------------- Database Table space One or more VSAM linear data sets Partition 1 Data set for partition 1 Partition 2 Data set for partition 2 Index VSAM data set(s), partitioned if applicable Growth path: free pages -> unused primary allocation -> secondary extent -> larger partition/data set -> new PBG partition -> hard boundary if no valid allocation remains The exact path depends on table-space type, partitioning, DSSIZE, MAXPARTITIONS, SMS policy, and available volumes.
Begin with a workload forecast rather than a copied PRIQTY. Estimate current rows, average row length, monthly growth, retention, purge policy, and peak ingestion. Include variable-length expansion, row overhead, page headers, space-map pages, free-space policy, and multiple table versions where relevant. Then estimate each index independently: key columns, included columns, RID size, expected entries, leaf-page density, nonleaf levels, and the effect of partitioning all consume space.
A useful forecast has at least three numbers: expected used space at the end of the planning period, normal allocated headroom, and the physical maximum. Add utility workspace, image copies, sort work, and recovery assets outside the page-set estimate. A 500 GB table can require substantially more than 500 GB of temporary and copy capacity during a major REORG. Work-file sizing is also based on peak concurrent spill demand, not the permanent table size or an average quiet-hour sample.
| Object | Base estimate | Additional reserve |
|---|---|---|
| Table space | Row length × expected rows, adjusted for page overhead and compression | Growth horizon, free space, versioning, and maintenance workspace |
| Index | Key length, RID size, entries, leaf density, nonleaf levels, and partitions | Leaf splits, new keys, index versions, and REBUILD or REORG workspace |
| LOB table space | Average external LOB bytes × rows, plus LOB structure overhead | Large-value growth, deleted LOB reclamation, and utility copies |
| Work files | Peak concurrent sort, hash, temporary-table, and spill demand | Workload spikes and utility or query concurrency, not average demand |
12345678910111213141516171819202122Example planning estimate ------------------------- Current rows 180,000,000 Average stored row bytes 220 Expected annual row growth 30% Planning horizon 2 years Projected rows = 180,000,000 × 1.30 × 1.30 = 304,200,000 Raw row bytes = 304,200,000 × 220 = 66,924,000,000 bytes Then add or model: page and row overhead PCTFREE / expected page occupancy compression estimate each index separately LOB and XML storage separately utility, copy, and growth headroom This is a forecast, not a CREATE TABLESPACE calculator.
PRIQTY specifies a minimum primary allocation, in kilobytes, for a Db2-managed data set. It affects the allocation when a new data set is created; changing it does not magically resize every existing extent. A primary quantity that is far below normal object size causes extension work soon after creation. One that is far above a realistic horizon can reserve capacity that other objects need.
SECQTY controls secondary allocation. If SECQTY is omitted in eligible CREATE statements, or an existing object is altered to SECQTY -1, Db2 uses a sliding-scale algorithm. Secondary extents grow as the data set grows, reducing the risk created by a permanently tiny fixed request. IBM documents that a specified SECQTY can still influence allocation when it is larger than the calculated minimum; the actual request also remains bounded by limits such as DSSIZE or index PIECESIZE.
SECQTY 0 is not a general growth strategy. It prevents secondary allocation in supported contexts and can turn exhaustion of the primary allocation into an immediate outage. Prefer Db2-managed growth unless measurements prove that a site-specific fixed value is better. Storage teams should also enable and validate the appropriate SMS extent relief policy rather than trying to compensate for obsolete limits with huge manual extents.
| Control | Meaning | Operational caution |
|---|---|---|
| PRIQTY | Minimum primary allocation for a Db2-managed data set | Too small causes early extensions; excessively large values strand capacity |
| SECQTY | Minimum secondary allocation, or -1 for Db2-managed calculation | Fixed values can age badly as the object grows |
| DSSIZE | Maximum addressable size of a data set or partition | Changing it can be pending DDL and must fit page-size and partition rules |
| MAXPARTITIONS | Maximum partitions for a partition-by-growth table space | Cannot be reduced below already allocated physical partitions |
| PCTFREE | Percentage of each page reserved during LOAD or REORG | Consumes capacity now to reduce future page splits and relocated rows |
| FREEPAGE | Leaves one free page after a specified number of loaded pages | Coarser than PCTFREE and not supported for every table-space type |
123456789101112131415161718-- Illustrative definitions; validate values for your Db2 level. CREATE TABLESPACE ORDERTS IN APPDB USING STOGROUP APPSTG PRIQTY -1 SECQTY -1 DSSIZE 32G MAXPARTITIONS 64 PCTFREE 10 COMPRESS YES; -- Return an existing Db2-managed object to calculated allocation. ALTER TABLESPACE APPDB.ORDERTS PRIQTY -1 SECQTY -1; -- DDL changes policy. It does not by itself compact existing data -- or guarantee that every physical attribute is materialized now.
DSSIZE specifies the maximum size of a data set for a table space or partition. It is a capacity boundary, not an initial allocation. For a partition-by-growth (PBG) universal table space, Db2 grows the current partition until the applicable boundary and then creates another partition, up to MAXPARTITIONS. IBM permits as many as 4096 partitions in supported combinations, but the valid maximum depends on DSSIZE and page size.
Partition-by-range (PBR) separates rows according to key boundaries; its sizing must account for skew. A year with unusual activity can fill one range while other partitions remain mostly empty. PBG avoids key-range skew but still needs a ceiling and maintenance plan. Monitor the size and growth of every partition, not only the sum for the table space. A healthy total percentage can hide one partition approaching its individual limit.
MAXPARTITIONS cannot be reduced below the number of physical partitions already allocated. Increasing it can extend the capacity envelope only when the page-size and DSSIZE combination permits the value. Raising a limit is not reclamation: if old data should have been purged, adding partitions merely delays the next boundary and increases utility and recovery scope.
Free space is deliberate room for change. PCTFREE reserves a percentage of each data page when data is loaded or reorganized. It helps an INSERT find room near the desired clustering position and gives an expanding variable-length row space to remain on its page. FREEPAGE leaves one whole empty page after a chosen number of populated pages. IBM permits FREEPAGE values from 0 through 255 for supported table spaces and PCTFREE values from 0 through 99.
These values describe the post-utility layout, not an inviolable reserve. Inserts and updates can consume it. Too little space can increase page splits, disorganized clustering, indirect references, and REORG pressure. Too much space increases page counts, I/O, buffer-pool demand, copy size, and utility elapsed time. Choose values from insert pattern, update expansion, clustering, and observed real-time statistics rather than from a universal percentage.
Db2 also supports PCTFREE FOR UPDATE behavior for eligible table spaces. It targets update expansion rather than general insert placement, and automatic behavior can use real-time statistics. After changing free-space attributes with ALTER, plan the utility that will rebuild existing pages if redistribution is required. Merely committing the ALTER does not move old rows.
Table-space compression stores more logical data in fewer pages. With COMPRESS YES, Db2 uses a compression method appropriate to the definition and active function level. Traditional fixed-length and newer Huffman approaches use dictionaries that represent recurring data patterns compactly. Dictionaries are built or rebuilt by eligible utility processing, and Db2 can also create a dictionary as data reaches the documented threshold in supported cases.
Compression changes every sizing equation. Estimate with representative production data by using tools such as DSN1COMP where appropriate, and do not assume another table's ratio. Highly repetitive character data often compresses well; already compressed, encrypted, or random bytes may not. A better ratio reduces allocated pages, I/O, copies, and buffer-pool pressure, but compression and expansion use processor resources. Measure total service and elapsed time, not DASD alone.
Index compression is different from table-space dictionary compression. Compressed indexes require an 8 KB, 16 KB, or 32 KB buffer pool. Leaf pages are compressed on disk and represented at the assigned larger page size in memory; no table-space-style dictionary performs that work. Changing index page size or compression can produce pending physical changes and require REBUILD INDEX or REORG. Include buffer-pool memory, I/O savings, utility time, and rollback in the decision.
An extent is a contiguous allocation acquired for a data set. The primary allocation is normally the first extent, and later growth uses secondary extents. A high extent count is not automatically a modern Db2 performance defect. Db2's sliding-scale allocation increases requests over time, while contemporary SMS and storage reduce the old performance penalty associated with physical discontinuity.
Extents still matter for availability. IBM documents up to 7257 extents when the SMS data class uses Extent Constraint Removal, while per-volume and volume-count rules still apply. A data set can also reach its DSSIZE before its extent count looks alarming. Monitor extents as one part of a boundary model that includes allocated bytes, active pages, last data set or piece, eligible volume capacity, and partition headroom.
Real-time statistics provide the best Db2-level operational feed. SYSIBM.SYSTABLESPACESTATS and SYSIBM.SYSINDEXSPACESTATS include SPACE in kilobytes and EXTENTS, along with active-page, row or entry, and maintenance information. For a multi-piece page set, read IBM's column definition carefully: SPACE can cover all pieces while EXTENTS can describe the last data set. Catalog definition values and storage-system data complete the picture.
1234567891011121314151617181920212223242526272829-- Table-space and partition growth snapshot SELECT DBNAME, NAME, PARTITION, SPACE, EXTENTS, NACTIVE, TOTALROWS, REORGLASTTIME, STATSLASTTIME FROM SYSIBM.SYSTABLESPACESTATS ORDER BY DBNAME, NAME, PARTITION WITH UR; -- Index-space growth snapshot SELECT DBNAME, NAME, PARTITION, SPACE, EXTENTS, NACTIVE, TOTALENTRIES, REBUILDLASTTIME FROM SYSIBM.SYSINDEXSPACESTATS ORDER BY DBNAME, NAME, PARTITION WITH UR; -- Column availability and types depend on catalog/function level. -- Validate against IBM documentation for the active subsystem.
A snapshot shows current state; a history shows risk. Capture regular samples and calculate growth per day or business cycle. Alert on forecast time to DSSIZE, remaining PBG partitions, abnormal acceleration, storage-group exhaustion, and repeated extension warnings. STOSPACE remains relevant for updating catalog space values used by traditional catalog queries, but do not confuse its last-run result with continuously maintained real-time statistics.
ALTER is not one kind of operation. PRIQTY and SECQTY change allocation policy for applicable future data-set creation or extension. PCTFREE and FREEPAGE alter the layout requested by future LOAD or REORG processing. DSSIZE, page-size-related choices, compression, and partition changes can be immediate, deferred, restricted, or pending depending on the object type and active Db2 level.
IBM notes that changing storage attributes for more than one partition requires separate ALTER TABLESPACE statements. USING or ERASE changes can require the target to be stopped. ALTER cannot proceed while a utility controls the object, and mixing some space ALTER activity with inserts in one commit scope can require an intervening COMMIT. Read the exact statement rules, check object state after DDL, and schedule any required REORG or recovery action.
An application can report SQLCODE -904 because the required page set or data set is unavailable. When the underlying reason is 00D70014, Db2 attempted to extend a data set and media manager reported a failure. IBM advises checking associated DSNP001I, DSNO007I, DSNP011I, or related messages. The volume might be full, the data set might have reached an allowable extent or size boundary, or another allocation problem might exist.
Do not respond by blindly increasing SECQTY. First identify the object and data set, partition or piece, current size, DSSIZE or PIECESIZE, extent count, storage group, candidate volumes, and recent growth. If a PBG space reached MAXPARTITIONS, adding volume capacity does not raise the partition ceiling. If a volume is full, changing PCTFREE does not make the failed extension succeed. If deleted data is reclaimable, REORG may be part of the long-term answer, but an emergency recovery procedure must follow the site's tested runbook.
123456789101112131415Allocation failure triage ------------------------- 1. Preserve SQLCODE, reason code, resource type, and DSNP/DSNO messages. 2. Resolve the Db2 object to its VSAM data set, partition, and piece. 3. Check: - allocated size versus DSSIZE / PIECESIZE - current partition count versus MAXPARTITIONS - extent count and SMS extent-relief policy - free capacity on eligible storage-group volumes - recent growth and abnormal load activity 4. Restore service with the approved storage/Db2 runbook. 5. Correct the forecast, allocation policy, retention, or physical design. Never delete, rename, or manually redefine a Db2-owned VSAM data set as an improvised space fix.
Imagine a toy room with shelves. PRIQTY is how much shelf space you get when the room opens. SECQTY is how much more shelf the helper adds when it fills up; SECQTY -1 lets the helper choose increasingly useful pieces. DSSIZE says how big one shelf can become, and MAXPARTITIONS says how many shelves the room may have. PCTFREE leaves little gaps beside toys so new toys fit without moving everything. Compression packs soft toys into smaller boxes. Extents are the extra shelf pieces added over time. A good manager counts the toys, watches how quickly shelves fill, and orders space before the last shelf is full.
1. What does SECQTY -1 request for a Db2-managed table space or index?
2. What is the main purpose of DSSIZE?
3. When do altered PCTFREE and FREEPAGE values normally reorganize existing data?
4. Which catalog tables provide real-time space and extent statistics?
5. Why can compression affect more than the DASD bill?
6. What should be investigated first after reason code 00D70014?
Explore table-space and index compression methods in greater detail
Understand partition-by-growth and partition-by-range physical design
Learn how REORG restores physical organization and materializes changes
Use Db2 object statistics to drive maintenance and capacity decisions