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 > order of null versus not null columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-04, 13:43
chimes1967 chimes1967 is offline
Registered User
 
Join Date: Feb 2003
Posts: 9
order of null versus not null columns

For UDB Version 8, AIX, are there any considerations, performance or otherwise on having nullable columns near the beginning of the table? In other words, when defining the table, are there performance considerations that dictate columns defined as nullable be put physically at the beggining or end of the table.

I believe I read something before about varchar fields should go near the end of the table, but that may have been for os/390 only.

Thanks,

Cliff.
Reply With Quote
  #2 (permalink)  
Old 05-19-04, 15:19
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
You are correct that on OS/390 you should put varchar at the end of the row (unless that has been changed in recent releases).

On DB2 for Linux, Unix, and Windows, the varchar columns are put at the end of the table automatically when the table is created.

I have never heard anything about null vs not null columns. Nullable columns require one extra byte for the null indicator.
__________________
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-19-04, 21:53
sundialsvcs sundialsvcs is offline
Registered User
 
Join Date: Oct 2003
Posts: 706
I feel confident in saying that nullable columns can be anywhere. In most storage formats there is usually a null-value indicator, either as an invisible first-byte of the column or as a bitmap stored with each column.

Generally, I don't recommend that you dwell too much on "efficiency" when you design your tables. That's really what the DBMS is supposed to be concerned with. Your concern is to be certain that the schema accurately represents what you need for it to be capable of storing.
__________________
ChimneySweep(R): fast, automatic
table repair at a click of the
mouse! http://www.sundialservices.com
Reply With Quote
  #4 (permalink)  
Old 05-20-04, 02:24
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi chimes1967,

I have read somewhere that the order of columns for performance reason is important.
The recomendation for order of columns in table was:
1. primary key columns,
2. not null columns,
3. null columns,
4. varchar columns.

I haven't tested this to confirm some performance benefits. I just write what I read...

Hope this helps,
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