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 > index definition

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-04-04, 18:15
jgn78 jgn78 is offline
Registered User
 
Join Date: Jan 2003
Posts: 6
Question index definition

Hi, I have a table with 2 indexes, the first one defined like:

column1, column2, column3

and the second one

column1, column2

I am not sure if a can eliminate index 2. I supouse that, if index 1 has column1 and column2, maybe DB2 could use index one to cover both cases, I mean, on a where clause, DB2 has to match the exact columns of an index to use it or just the first columns ?

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-04-04, 18:37
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
You should definitely drop the second index, it is redundent. If the second index was on (column2, column3) that would be different.
__________________
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
  #3 (permalink)  
Old 03-05-04, 06:27
Walter Janissen Walter Janissen is offline
Registered User
 
Join Date: Nov 2003
Location: Germany
Posts: 62
The second index is only redundant, if it is not unique, but if it is unique, you will loose the uniqueness on these two columns. So, may be the first index is redundant or only makes sense, if there are queries, where the access path becomes index only.
Reply With Quote
  #4 (permalink)  
Old 03-06-04, 19:22
GertK GertK is offline
Registered User
 
Join Date: Nov 2003
Location: Netherlands
Posts: 96
Quote:
Originally posted by Walter Janissen
The second index is only redundant, if it is not unique, but if it is unique, you will loose the uniqueness on these two columns. So, may be the first index is redundant or only makes sense, if there are queries, where the access path becomes index only.
You're right, but it's also possible to include columns in the index which are not part of the index key.

CREATE UNIQUE INDEX INDEX1 on TABLE1 (COLUMN1, COLUMN2) INCLUDE (COLUMN3)

which makes the second index redundant (this might be different on DB2 OS/390)
Reply With Quote
  #5 (permalink)  
Old 03-08-04, 02:50
Walter Janissen Walter Janissen is offline
Registered User
 
Join Date: Nov 2003
Location: Germany
Posts: 62
Yes this is different for DB2 z/OS. Even in Version 8 that will not be supported.
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