× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Actually, name might be a very good candidate for variable length fields.

Consider..

fullName = %trimr(firstName) + ' ' +%trimr(lastName);

vs.

fullName = firstName + ' ' + lastName;

%trim() is costly. If you're using it a lot, you'd be better off with variable name fields. Same
applies to %len() and most the other string manipulation BIFs.

Thus: for fields which may be subject to or otherwise require such BIFs variable length is a better
choice. Instead of fixed length names, I'd certainly have name fields variable length and simply
allocate them at their max length.

NAME 30 VARLEN(30)

You get the non-overflow benefits of fixed-length with the string manipulation benefits of variable
length. The price you pay is an extra couple of bytes in the DB and an insignificant bit of overhead
when the value changes.

HTH,

Charles Wilt
--
Software Engineer
CINTAS Corporation - IT 92B
513.701.1307

wiltc@xxxxxxxxxx


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-
bounces@xxxxxxxxxxxx] On Behalf Of Mike Cunningham
Sent: Thursday, August 14, 2008 12:54 PM
To: 'Midrange Systems Technical Discussion'
Subject: RE: Database character fields

Yes, the DB2/400 parts all make sense and I was aware of the rules-of-
thumb on how to setup variable length fields and the average actual use to
reduced hits on overflow access. To me (and from the perspective of
DB2/400) fixed length fields are better than variable length fields if you
have a very good idea on the data that will be going in the field. To me a
last name field which on average might hold 10 characters but might hold
30 is not a candidate for variable length. A field that holds a
description for a class (I work at a college) that might be 100 characters
for most but could be 1,000 for a few, is a good candidate for variable
length. Yet when I look at MS SQL columns just about all character fields
are defined as variable length. Got my curiosity up to want to understand
why.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-
bounces@xxxxxxxxxxxx] On Behalf Of Mark S. Waterbury
Sent: Thursday, August 14, 2008 10:31 AM
To: Midrange Systems Technical Discussion
Subject: Re: Database character fields

Hi, Mike:

I don't know about those other databases, but with DB2/400, I suggest
you define your VARCHAR fields with a minimum length that should be
large enough to contain the "average" or most frequently occuring
strings. That way, most of the time, the data will just fit right there,
within the fixed portion of the record, where that space for that field
is allocated. Only when the data does not fit within this space, will
DB2/400 be forced to use the "overflow" technique. Note that, in this
case, the entire "fixed" area is unused (blank or nulls) and the entire
varchar string data is stored in the overflow area for that record.

So by carefully choosing the minimum or default size to allocate for
those fields, you can ensure that, 80% or 90% of the time, you will not
incur any additional overhead.

Does that "make sense"?

Regards,

Mark S. Waterbury

> Mike Cunningham wrote:
Not looking to start a war over which is better, just looking to update
my knowledge.

When we create character fields in DB2/400 we usually setup fixed
length, no null support fields. If the character fields is long (e.g. 100+
bytes) and we suspect the data will vary greatly in actually used length,
we will make it a variable length field. The only time we use null fields
is for data we are importing in from other systems where the file can have
null values. In those cases the file with null field support is usually a
work file used for the import and they we move the data into non-null
fields in the production files. In other databases (like MS SQL) the
standard looks like it is just the opposite. All character fields are
variable length with null support unless you take extra steps to not do
that. My training (and it has been some years) said that variable length
fields are good for saving storage space but bad for overhead. That the
database had to do extra work to manage the variable length, tracking the
actually number of bytes in use and manage the !

ov!
erflow areas when the data in the fields changed from 10 characters to
1,000 and back to 10. Is it still true that variable length fields are
less efficient and if so why do other databases have that as the default?
Or is this something specific to the implementation of the database? Is
DB2/400 move efficient with fixed length but MS SQL more efficient with
variable length?

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.




This e-mail transmission contains information that is intended to be confidential and privileged. If you receive this e-mail and you are not a named addressee you are hereby notified that you are not authorized to read, print, retain, copy or disseminate this communication without the consent of the sender and that doing so is prohibited and may be unlawful. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please delete and otherwise erase it and any attachments from your computer system. Your assistance in correcting this error is appreciated.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.