Databases 10 min read

Mastering DB2 Indexes: Scan Types, Design Principles, and Deep Cleanup Strategies

This article explains DB2 index scan methods, how predicates are applied on indexed columns, practical guidelines for designing efficient indexes, ways to avoid redundant or overly complex indexes, and step‑by‑step techniques for deep index cleanup using DB2 utilities and system catalog queries.

dbaplus Community
dbaplus Community
dbaplus Community
Mastering DB2 Indexes: Scan Types, Design Principles, and Deep Cleanup Strategies

Deep Index Cleanup

DB2 V9.5 and Earlier

Run the command: db2pd -d <DBName> -tcb index[all] Examine the “TCB Index Stats” block, focusing on the Scans and IxOnlyScns columns. An index with values orders of magnitude lower than other indexes on the same table is likely rarely used and can be considered for removal. Note that db2pd reports statistics accumulated since the database was activated; a long uptime that covers typical business cycles yields more reliable data.

DB2 V9.7 and Later

Query the system view SYSCAT.INDEXES.LASTUSED to obtain the last usage date of each index.

SELECT INDNAME, LASTUSED, CREATE_TIME
FROM SYSCAT.INDEXES
WHERE TABNAME = '<TABLE>';

If LASTUSED = '0001-01-01', the index has never been used since creation. Combine this with CREATE_TIME and the business cycle to decide whether to keep it.

For indexes with a non‑default LASTUSED, also consider the scan counts from db2pd to distinguish infrequently used indexes from those used only occasionally.

Assess index clustering efficiency via SYSCAT.INDEXES.CLUSTERRATIO or by comparing FULLKEYCARD with SYSCAT.TABLES.CARD. A low clustering ratio indicates poor data locality and higher maintenance cost, suggesting the index may be a candidate for removal.

Before dropping any index, ensure that statistics are up‑to‑date; stale statistics can lead to mis‑identification. Treat primary (type P) and unique (type U) indexes with extra caution, as they often enforce business constraints.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performanceSQLDatabase OptimizationindexesDB2
dbaplus Community
Written by

dbaplus Community

Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.