Returns metrics for space use in SAP ASE as a comma-separated string.
spaceusage(db_id [, object_id [, index_id [, partition_id ] ] ] )
select spaceusage() "reserved pages=1163, used pages=494, data pages=411, index pages=78, oam pages=83, allocation units=94, row count=50529, tables=33, LOB pages=3, syslog pages=8"
select spaceusage(dbid, objid)
select spaceusage(database_id, object_id, index_id)
select spaceusage(db_id(), object_id('syspartitions')) ---------------------------------------------------------------------- reserved pages=2220, used pages=2104, data pages=2100, index pages=1096, oam pages=4, allocation units=373, row count=174522, tables=1, LOB pages=0
In this result, the reserved pages, used pages, and data pages values report the respective page counts for data and index pages. Because index pages reports the page counts for only the index pages of the three indexes on syspartitions, determine the number of data pages for only the data layer of this table by subtracting the value for index pages from the value for the data pages: 2100 - 1096 = 1004 pages.
select spaceusage(db_id(), object_id('syspartitions'), 0) ---------------------------------------------------------------------- reserved pages=1064, used pages=1005, data pages=1004, index pages=0, oam pages=1, allocation units=229, row count=174522, tables=1, LOB pages=0
spaceusage reports a value for data pages (1004), which is consistent with the equation above, and because the query requests space metrics for only the data layer, it returns a value of 0 for the index pages.
select spaceusage(database_id)
However, spaceusage does not report on tables that do not occupy space (for example, fake and proxy tables). Currently, spaceusage also does not report on syslogs.
The value for used pages that spaceusage returns when you specify index_id = 1 (that is, for all-pages clustered indexes) is the used page count for the index layer of the clustered index. However, the value the used_pages function returns when you specify index_id = 1 includes the used page counts for the data and the index layers.
spaceusage(database_id, object_id, index_id)
oam pages indicates the number of OAM pages found for this index and any of its local index partitions. If you run spaceusage against a specific object, oam pages returns the amount of overhead for the extra pages used for this object’s space management.
When you execute spaceusage for an entire database, oam pages returns the total overhead for the number of OAM pages needed to track space across all objects, and their off-row LOB columns.
When you run spaceusage against the entire database, allocation units returns the total number of allocation units reserving space for an object. However, because Adaptive Server can share allocation units across objects, this field might show a number greater than the total number of allocation units in the entire database.
LOB pages returns a nonzero value only when you use spaceusage to determine the space metrics for all indexes, or only the LOB index, on objects that contain off-row LOB data. LOB pages returns 0 when you use spaceusage to examine the space metrics only for tables (which have index IDs of 0).
When you run spaceusage against the entire database, LOB pages displays the aggregate page counts for all LOB columns occupying off-row storage in all objects.