Detecting indexes, tables and packages not used on DB2

DB2, from version 9.7, allows to know easily what indexes are not being used in a Database. The query is also for tables and packages.

This is a useful tool for tuning indexes and detecting problems in their use.

After version 9.7 DB2 includes a new LASTUSED field in the SYSCAT.INDEXES, SYSCAT.TABLES and SYSCAT.PACKAGES tables.

This field indicates the date of last use of indexes, tables or packages.

For example, to query unused indexes since 1/1/2019, you could use this simple query:

TOP 10 rows on DB2

In this shosrt post we will show how to obtain the N first rows from a Query on IBM DB2.

With Oracle SQL would be with ROWNUM, and with SQL Server we'd use TOP.

 

This is the Top 10 query syntax:

select *

from My_Table

fetch first 10 rows only