IBM Support

In DB2 9.x, a query against SYSIBMADM.ADMINTABINFO is too slow

Troubleshooting


Problem

When querying against the administrative view SYSIBMADM.ADMINTABINFO, the query takes too long to return even though the query is filtered by table name: e.g. select * from sysibmadm.admintabinfo where tabname = '

'

Symptom

Simple queries against the SYSIBMADM.ADMINTABINFO view are very slow

Cause

The ADMINTABINFO is defined as a view in which it calls the corresponding table function without specifying a schema or table.

From the following query, one can see the definition of this view:

select text from syscat.views where viewname = 'ADMINTABINFO'


CREATE VIEW SYSIBMADM.ADMINTABINFO  (TABSCHEMA, TABNAME, TABTYPE, DBPARTITIONNUM, DATA_PARTITION_ID,  AVAILABLE, DATA_OBJECT_L_SIZE, DATA_OBJECT_P_SIZE,  INDEX_OBJECT_L_SIZE, INDEX_OBJECT_P_SIZE, LONG_OBJECT_L_SIZE,  LONG_OBJECT_P_SIZE, LOB_OBJECT_L_SIZE, LOB_OBJECT_P_SIZE,  XML_OBJECT_L_SIZE, XML_OBJECT_P_SIZE, INDEX_TYPE, REORG_PENDING,  INPLACE_REORG_STATUS, LOAD_STATUS, READ_ACCESS_ONLY, NO_LOAD_RESTART,  NUM_REORG_REC_ALTERS, INDEXES_REQUIRE_REBUILD, LARGE_RIDS,  LARGE_SLOTS, DICTIONARY_SIZE ) AS SELECT  TABINFO.TABSCHEMA, TABINFO.TABNAME, TABINFO.TABTYPE,  TABINFO.DBPARTITIONNUM, TABINFO.DATA_PARTITION_ID, TABINFO.AVAILABLE,  TABINFO.DATA_OBJECT_L_SIZE, TABINFO.DATA_OBJECT_P_SIZE,  TABINFO.INDEX_OBJECT_L_SIZE, TABINFO.INDEX_OBJECT_P_SIZE,  TABINFO.LONG_OBJECT_L_SIZE, TABINFO.LONG_OBJECT_P_SIZE,  TABINFO.LOB_OBJECT_L_SIZE, TABINFO.LOB_OBJECT_P_SIZE,  TABINFO.XML_OBJECT_L_SIZE, TABINFO.XML_OBJECT_P_SIZE,  TABINFO.INDEX_TYPE, TABINFO.REORG_PENDING, TABINFO.INPLACE_REORG_STATUS,  TABINFO.LOAD_STATUS, TABINFO.READ_ACCESS_ONLY, TABINFO.NO_LOAD_RESTART,  TABINFO.NUM_REORG_REC_ALTERS, TABINFO.INDEXES_REQUIRE_REBUILD, TABINFO.LARGE_RIDS,  TABINFO.LARGE_SLOTS, TABINFO.DICTIONARY_SIZE FROM TABLE(SYSPROC.ADMIN_GET_TAB_INFO( '', '')) AS TABINFO      

The above output is generated in DB2 v9.1

As seen in the definition, each time you query against the ADMINTABINFO, it's calling the table function underneath to retrieve info for every single table in the database. The query filter condition (for example, tabname = 'xxxxxx') is applied against the function results only after all the information has already been retrieved for all tables. In other words, though one may technically filter the query against this view, the filter is merely cosmetically omitting the unwanted rows; underneath, it is always retrieving table info for all tables regardless of the filter condition.

Therefore, running

select * from sysibmadm.admintabinfo where tabschema = '<schemaname>' and tabname = '<tablename>'

is NOT equivalent to

select * from table(sysproc.admin_get_tab_info('<schemaname>','<tablename>')) as a


The latter is expected to be much faster.

Environment

The database has a large number of tables

Resolving The Problem

Use the table function instead of the administrative view. The function name is different depending on the version:

v9.1 - SYSPROC.ADMIN_GET_TAB_INFO
v9.5 - SYSPROC.ADMIN_GET_TAB_INFO_V95
v9.7 - SYSPROC.ADMIN_GET_TAB_INFO_V97

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Performance - Admin views and table functions","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"},{"code":"PF010","label":"HP-UX"},{"code":"PF033","label":"Windows"},{"code":"PF027","label":"Solaris"}],"Version":"9.1;9.5;9.7","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21438859