If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > are these indexes being used?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-27-09, 13:57
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
are these indexes being used?

DB2 9.5 LUW

Is there a catalog table or something that I can query to find out which indexes are being utilized?

We have spent the last year or so building up our Data Mart and in looking at all of the indexes that we have deployed - I'm thinking we are not utilizing all of them.

Is there any way to report on this?
Reply With Quote
  #2 (permalink)  
Old 05-27-09, 13:59
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
It was just talked about it last week I think.

db2pd is the best tool to hunt for unused indexes:
Code:

db2pd -db sample -tcbstats index

Look for the "TCB Index Stats:" header and the "Scans" column.
This will tell you how many times DB2 used that index. If the counter is ZERO, DB2 did not need that index at all so.......
Be ware:
1 - when a database stops and starts again all the counters are reset to ZERO
2 - beware of FK contraints. The index might be required as FK.

You do need SYSADM access
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #3 (permalink)  
Old 05-27-09, 15:35
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
I know this is going to sound stupid.. but what is the correct syntax to run this from COMMAND EDITOR?

I try and run it like this:

db2pd -db PRODDM -tcbstats index

and I get this:

DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "db2pd -db" was found following
"BEGIN-OF-STATEMENT". Expected tokens may include: "<values>".
SQLSTATE=42601
Reply With Quote
  #4 (permalink)  
Old 05-27-09, 15:40
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #5 (permalink)  
Old 05-27-09, 15:42
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
Thank you!
Reply With Quote
  #6 (permalink)  
Old 06-04-09, 15:16
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
Can anyone tell me how to find the tableid? I need it to run DB2PD like this:


db2pd -db PRODDM -tcbstats index tbspaceid = 3 tableid = xxx
Reply With Quote
  #7 (permalink)  
Old 06-04-09, 15:26
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by itsonlyme44
Can anyone tell me how to find the tableid?
It is in SYSCAT.TABLES, obviously.
Reply With Quote
  #8 (permalink)  
Old 06-04-09, 16:10
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
Thank you!!! I missed that... I work more with SQL Server and was looking for an object table...

anyway.. can anyone help me interpret the output from this:

Code:
>db2pd -db PRODDM -tcbstats index  > c:\PRODDM_Stats.txt
Code:
TCB Index Stats:
Address    TableName          IID   EmpPgDel   RootSplits BndrySplts PseuEmptPg Scans      KeyUpdates InclUpdats NonBndSpts PgAllocs   Merges     PseuDels   DelClean   IntNodSpl  0          0          0          0          0          0          0          0          0          0          0          0          0          
0x59456DA8 T9DAT              2     0          0          0          0          16         0          0          0          0          0          0          0          0          
0x59456DA8 T9DAT              1     0          0          0          0          9          0          0          0          0          0          0          0          0          
0x59458028 T9PH               1     0          0          0          0          0          0          0          0          0          0          0          0          0          
0x59455728 T9PSC              2     0          0          0          0          26         0          0          0          0          0          0          0          0          
0x59455728 T9PSC              1     0          0          0          0          1          0          0          0          0          0          0          0          0          
0x5945EC28 T9PSR              2     0          0          0          0          2          0          0          0          0          0          0          0          0          
0x5945EC28 T9PSR              1     0          0          0          0          0          0          0          0          0          0          0          0          0
For instance I have mulitiple indexes on the tables listed.. so how do I know which indexes are being used?
Reply With Quote
  #9 (permalink)  
Old 06-04-09, 16:22
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
this information is only current from the last time instance was cycled.

As I understand "scans" column tells you number of times index was used. You might not want to base your decision based on one output. I would collect the info for at least a couple of month and decide then.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #10 (permalink)  
Old 06-04-09, 18:42
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by Cougar8000
this information is only current from the last time instance was cycled.
I'd say it has accumulated since the time of the database activation, which may or may not coincide with the start of the instance.
Reply With Quote
  #11 (permalink)  
Old 06-05-09, 05:41
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
I see now.. the IID is the index ID. lots of crosschecking involved to figure out which index is which (we have a couple hundred tables in our datamart with up to 5 indexes on each table) but the information on index useage is well worth the trouble.. thank you for your help
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On