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 question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-17-06, 11:14
cougartrace cougartrace is offline
Registered User
 
Join Date: Oct 2005
Posts: 26
index question

I have programs that will utilize index I. I also have programs that will utilize index J. Can I combine the the two indexes into like the example index K below (and both pograms be happy)?

Index I:
Column A
Column B

Index J:
Column A
Column C

Index K:
Column A
Column B
Column C

Thanks,

CougarTrace

Last edited by cougartrace; 05-17-06 at 11:33. Reason: better explanation
Reply With Quote
  #2 (permalink)  
Old 05-17-06, 11:48
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Index I is redundant based on the existence of index K.

Index J should be turned around to be:
Column C
Column A

But it is possible that index J is also redundant if the cardinality of Column A is high enough on index K.
__________________
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 05-17-06, 16:18
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
I'd not advice to combine the two indices.

If you have a WHERE-Clause like:
WHERE A = .... AND C = ....
the "new" index K has only 1 matching column ( instead of 2, which Index J has ) and that will result in more get-page-requests and a poorer performance.

Programs that use Index I ( with a WHERE-CLause :
WHERE A = ... AND B = .... )
wouldn't be happy too. The additional column might require to read more index-pages.


What would benefit from the combination ?
- each insert / delete / update - as only one index has to be updated
- a SELECT c FROM ... WHERE a = ... AND b = ... - as the query is index-only
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