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 > how many columns can i have for PK

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-05-05, 10:59
dba_udb dba_udb is offline
Registered User
 
Join Date: Mar 2005
Posts: 73
how many columns can i have for PK

UDB : v8.2
OS : Solaris

How many columns can i have for a PK.
I am seeing 4 -5 columns as PK for few tables?
what is the impact of having these many columns as PK.

Will it have any effect while loading ,deleting data?

Any inputs are welcome

thanks
Reply With Quote
  #2 (permalink)  
Old 10-05-05, 11:16
bmujeeb bmujeeb is offline
Registered User
 
Join Date: Mar 2004
Posts: 448
Any time you update/delete , you made changes to the indexes as part of
automatic index maintainence(done by db2), so more columns also more log
generation.


regards,

mujeeb
Reply With Quote
  #3 (permalink)  
Old 10-05-05, 11:18
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
According to the manual (SQL Reference - Vol 1 - Appendix A - SQL Limits, 16 columns is the limit for an index (which is what a PK will be).

We have several tables that have 4-6 columns for the PK. The performance seems to be OK. The only drawback is doing joins to these tables and having to write the sql for all those columns.

Andy
Reply With Quote
  #4 (permalink)  
Old 10-05-05, 13:54
dba_udb dba_udb is offline
Registered User
 
Join Date: Mar 2005
Posts: 73
thanks Mujeeb and AR Winner
Reply With Quote
  #5 (permalink)  
Old 10-05-05, 21:00
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
The total length of the PK, and the order of the columns, is more important than the number of columns. If possible, put columns with higher cardinarlity up front, even if it does not seem as logical.

However, if any of the columns of the PK are changed, that could slow things down a bit, and in that case it is often advisable to use non-meaningfull keys.
__________________
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
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