IBM Support

Querying for table sizes

Question & Answer


Question

How can I query for table sizes (like nzstats -type table)?

Answer

On release 2.5 or earlier, to learn the size of tables, issue the following query from the system database.

SELECT

'Table '::varchar(9) AS "Object", RPAD (the_table.objname, 32)::varchar(32) AS "Name",
    the_database.objname AS "DBName",
    the_user.usename,

TO_CHAR ( SUM ( bytes ) , '99,999,999,999,999' ) AS "Bytes",
TO_CHAR ( SUM ( bytes ) / ( 1024 ) , '99,999,999,999' ) AS "KB",
TO_CHAR ( SUM ( bytes ) / ( 1048576 ) , '99,999,999' ) AS "MB",
TO_CHAR ( SUM ( bytes ) / ( 1073741824 ) , '99,999.0') AS "GB",
TO_CHAR ( SUM ( bytes ) / ( 1099511627776 ) , '999.0') AS "TB"

FROM
    _vt_spu_table_info,
    _t_dslice,
    _t_object the_table,
    _t_object the_database,
    _t_user the_user
WHERE
    _vt_spu_table_info.hwid = _t_dslice.ds_pridskid AND
    _vt_spu_table_info.data_part = _t_dslice.ds_priptid AND
    the_table.objid = _vt_spu_table_info.tblid AND
    the_table.objid >= 200000 AND
    _vt_spu_table_info.tblid >= 200000 AND
    the_table.objdb = the_database.objid AND
    the_table.objowner = the_user.usesysid
GROUP BY 4,3,1,2

[{"Product":{"code":"SSULQD","label":"IBM PureData System"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":null,"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

NZ341984

Document Information

More support for:
IBM PureData System

Software version:
1.0.0

Document number:
196605

Modified date:
17 October 2019

UID

swg21577191