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 > Is this redudant index?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-25-07, 05:32
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Is this redudant index?

Hi,
on my system DB2 v8 fp9 on Windows XP SP2 I run db2advis command for one particular SQL.

The output recommending indexes was:
Code:
CREATE INDEX ADMIN.IDX710250925460000 ON ADMIN.TAB1 
(COL1 ASC, COL2 ASC, COL3 ASC) ALLOW REVERSE SCANS ;

CREATE INDEX ADMIN.IDX710250926010000 ON ADMIN.TAB1
(COL1 ASC, COL2 ASC, COL3 ASC, COL4 ASC) ALLOW REVERSE SCANS ;
This output surprised me. Isn't first index redundant?

Thanks,
Grofaty
Reply With Quote
  #2 (permalink)  
Old 10-25-07, 06:55
guyprzytula guyprzytula is offline
Registered User
 
Join Date: Jun 2006
Posts: 471
yes, according my opinion first index is included in second
__________________
Best Regards, Guy Przytula
DB2 UDB LUW certified V6/7/8
Reply With Quote
  #3 (permalink)  
Old 10-25-07, 07:41
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Right, it is included.

However, the 2nd index may be bigger because index keys are longer and less keys may fit in an index page, requiring more pages. More pages may lead to a higher index tree. Thus, it could be beneficial to have both indexes - depending on what you do with the database.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 10-25-07, 10:17
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
IMO db2advis sucks. I have seen it generate indexes with descending sequence on columns for absolutely no good reason.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 10-26-07, 02:15
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
thanks for your comments. I have made an explain and with two indexes explain was better in third decimal. I have executed SQL with two indexes and with only with second one and the execution time was the same (differences is about a second). So I dropped first index.

Marcus_A, I have seen some strange suggestions from db2advis too. But sometimes I like to see second opinion to get some extra idea. Specially if there is a complex SQL to handle.

Thanks,
Grofaty
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