INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Better Choice: 1) NULL field, or 2) 0-byte VARCHAR field?

Better Choice: 1) NULL field, or 2) 0-byte VARCHAR field?

Better Choice: 1) NULL field, or 2) 0-byte VARCHAR field?

(OP)
Platform:  IBM MVS mainframe running DB2 v9
Given:     a table contains a column which is defined as VARCHAR(20), and which is nullable

Question:  Which is more efficient (or simply better for whatever reason):  1) to use the NULL indicator to indicate the absence of a value in that particular column, or 2) to set the length of the field to 0 (zero)?

Thanks for your input!

RichinMinn
 

RE: Better Choice: 1) NULL field, or 2) 0-byte VARCHAR field?

Well, as i'm anti-null, i'd choose the zero length. . .

If this was "my" data, i'd make the column not nullable. . .

 

RE: Better Choice: 1) NULL field, or 2) 0-byte VARCHAR field?

An interesting question.

In terms of the amount of space being taken up, then VARCHAR is more efficient as a nullable column of 20 bytes will always take up 21 bytes, the extra being the null indicator. That happens irresepctive of whether the column contains a value or not. With VARCHAR, the column will always take up at least 1 byte, with a maximum of 21.

There's an overhead involved for DB2 to check whether the column contains a value, but I think that this overhead is the same for both VARCHAR and NULL columns.

N.B
I believe that there is a compress option available in DB2 that will compress data when it doesn't exist, but I don't think this is available on a mainframe.

Marc

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close