CREATE STOGROUP tells DB2 which volumes (or SMS storage classes) may hold table spaces and indexes. It does not, by itself, keep a running total of how much DASD those objects actually occupy. The STOSPACE utility walks the z/OS integrated catalog for the data sets in a storage group and writes allocated kilobytes into the Db2 catalog. This page covers the STOSPACE statement, the SPACE and SPACEF columns, STATSTIME, why zero does not always mean empty, and how STOSPACE differs from RUNSTATS and real-time statistics.
Db2-managed objects (USING STOGROUP) are linear VSAM data sets. The ICF catalog knows primary and secondary allocation. STOSPACE asks that catalog “how many kilobytes are allocated?” and stores the answer. It does not read table pages, does not compress data, and does not change PRIQTY or SECQTY. Phases are UTILINIT, STOSPACE, and UTILTERM. IBM documents that STOSPACE can run concurrently with other utilities: the target is catalog columns, not a drain of the user table space.
Allocated space is not the same as used space. A table space can have a 100-cylinder data set that is only 10% full. STOSPACE reports the 100 cylinders (as kilobytes). SYSTABLESPACESTATS.NACTIVE and similar RTS columns describe pages that contain data. RUNSTATS describes data distribution for SQL access paths. Capacity planning needs all three views; STOSPACE is the allocated-DASD view.
The control statement is short. You name one storage group or all of them.
123STOSPACE STOGROUP (PAYSTO); STOSPACE STOGROUP (*);
There is no TABLESPACE keyword. You do not list partitions. If an object was created USING VCAT, it is not “in” a STOGROUP, so this utility will not attribute its DASD to a group. To measure those data sets you use IDCAMS LISTCAT, DFSMS reports, or vendor space tools—not STOSPACE.
12345//STOSP EXEC DSNUPROC,SYSTEM=DB2T,UID='DBA.STOSPACE' //SYSPRINT DD SYSOUT=* //SYSIN DD * STOSPACE STOGROUP (*) /*
SYSIN and SYSPRINT are required. No COPYDDN, no SYSUT1. Schedule the job after large LOAD, REORG, or growth weekends so SPACE does not lag reality by months. A common standard is weekly on high-activity STOGROUPs and monthly with (*).
| Catalog table | Columns |
|---|---|
| SYSIBM.SYSSTOGROUP | SPACE or SPACEF; STATSTIME (and historically SPCDATE) |
| SYSIBM.SYSTABLESPACE | SPACE or SPACEF — total allocated KB for the table space |
| SYSIBM.SYSTABLEPART | SPACE or SPACEF — allocated KB for each partition or data set |
| SYSIBM.SYSINDEXES | SPACE or SPACEF — total allocated KB; partitioned indexes sum STOGROUP partitions |
| SYSIBM.SYSINDEXPART | SPACE or SPACEF — allocated KB per index partition or piece |
SPACE is an INTEGER number of kilobytes. On a partitioned index, SYSINDEXES.SPACE is the total for all partitions that are defined in a storage group. If the true allocated value is larger than SPACE can hold, Db2 uses SPACEF (a floating column) instead. Queries that only select SPACE can under-report huge table spaces. Prefer:
1234567SELECT NAME, SPACE, SPACEF, STATSTIME FROM SYSIBM.SYSSTOGROUP ORDER BY NAME; SELECT DBNAME, NAME, SPACE, SPACEF FROM SYSIBM.SYSTABLESPACE WHERE DBNAME = 'PAYDB';
SYSIBM.SYSSTOGROUP.STATSTIME is the timestamp of the last successful STOSPACE for that group. If STATSTIME is years old, your SPACE numbers are a snapshot of an old ICF catalog, not tonight’s DASD. Older catalogs also had SPCDATE (yyddd); modern reporting should use STATSTIME.
IBM: the number of kilobytes of DASD allocated to the index as determined by the last STOSPACE. The value is 0 if the index is not related to a storage group, or if STOSPACE has not been run. For a partitioned index space, it is the total for all partitions defined in a storage group. That “0” is the same story as on table spaces: user-managed, never-run, or nothing allocated that the ICF catalog still shows.
After STOSPACE, SPACE = 0 on SYSSTOGROUP looks like “nothing lives here.” Three innocent explanations exist before you DROP STOGROUP:
12345678910SELECT ST.NAME, ST.SPACE, ST.SPACEF, ST.STATSTIME FROM SYSIBM.SYSSTOGROUP ST WHERE ST.SPACE = 0 AND ST.SPACEF = 0 AND NOT EXISTS ( SELECT 1 FROM SYSIBM.SYSTABLEPART TP WHERE TP.STORNAME = ST.NAME) AND NOT EXISTS ( SELECT 1 FROM SYSIBM.SYSINDEXPART IP WHERE IP.STORNAME = ST.NAME);
Only if that query returns the group and you have checked HSM and pending CREATE/DEFINE NO objects should you consider DROP STOGROUP. DEFINE NO table spaces have no data set until the first insert; STOSPACE will not invent allocation that does not exist yet.
STOSPACE updates catalog rows, so other jobs that hammer catalog indexes can time out the same way CATMAINT can—just far less dramatically, because STOSPACE is a catalog-column update, not a catalog-structure change. It does not put user table spaces in UTRW beyond ordinary catalog locking.
You can STOSPACE storage groups that contain objects in a work-file or declared-global temporary-table database (AS TEMP). IBM explicitly allows STOSPACE (and REPAIR DBD) on those temporary objects; LOAD, COPY, and REORG cannot run on declared temporary tables. That matters in shops that size DSNDB07 STOGROUPs and want catalog SPACE to match the work-file volumes.
STOSPACE is in the Db2 Utilities Suite, unlike REPORT and QUIESCE which are in the base set. Catalog and directory objects still run without the suite; user STOGROUP maintenance is a suite utility.
If SPACE and LISTCAT disagree, STOSPACE is stale—rerun it. If SPACE and RTS disagree, that is expected: allocated versus used. If you need to free DASD, REORG with a smaller PRIQTY, DROP unused objects, or migrate—STOSPACE will only report the new allocation after you do the work.
A storage group is a labeled shelf in the warehouse. STOSPACE is a person with a tape measure who writes “this shelf uses 40 boxes of space” on a clipboard (the Db2 catalog). The clipboard is not the boxes. Measuring does not throw boxes away and does not count how full each box is—that is a different clipboard (RTS). If the warehouse robot moved boxes to the basement (HSM migrate), the tape measure might say zero even though the labels still belong to that shelf. RUNSTATS is counting crayons inside the boxes so the teacher can plan lessons; STOSPACE is only how much floor space the boxes take.
1. What does STOSPACE update?
2. STOSPACE STOGROUP (*) means:
3. Why can SPACE be 0 after STOSPACE?
4. SPACE versus SPACEF:
5. Can STOSPACE run while COPY is running on the same table space?