MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » July 2014

AW: Variable length fields question



fixed

I found it in a presentation "DB2 UDB for iSeries: Coding Techniques for SQL
Performance" from Kent Milligan

"Internally, DB2 UDB for iSeries will automatically set the Allocate value
to the maximum
length of the variable length column whenever the column length is 30 bytes
or less."

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von
Charles Wilt
Gesendet: Wednesday, 30.7 2014 15:01
An: Midrange Systems Technical Discussion
Betreff: Re: Variable length fields question

Then only reason to use VARLEN with a 30 character field would be if you
have lots of %trimr() and or %len() in your code.

If the field was variable length, you could remove all the %trimr() except
where you are writing to the DB from a fixed length source such as a screen
and the %len() op-code would perform better as it wouldn't have to actually
count characters; the current length of a variable length field is always
already known.

FYI: I seem to recall hearing that (with SQL DDL?) if you left off the
allocate clause for a field or 30 chars or less the DB defaulted the
allocation to the length of the field. However, I can't find a reference
for this information and per the manual, allocate is defaulted to 0.

Charles


On Tue, Jul 29, 2014 at 5:07 PM, Voris, John <john.voris@xxxxxxxxxxxxx>
wrote:

I have been following the discussion with interest.
"The OS is smart enough to pad out the field" when processing, and RPG
buffers are sized at the maximum."

Here is our case: our Bill of Lading numbers are defined as 30A. But
in one file, CUPMIFH, the BOL was defined as 15A.
Most of our Bills of Lading are 7 or 8 char, and it was only once or
twice we found the 15A exceeded.
We have installed a fix in the RPG program where this surfaced as a
problem, so we have the problem resolved for now.

But when / if we were to address this mismatch . . . by redefining the
problem file, . . . would it make sense to define the BOL field as 30A
VARLEN(15) ?
Are there any advantages to making the field VARLEN ?

.+ One advantage we see is that SQL joins would be more reliable and
simpler to construct.
. - But we still have to recompile all RPG programs that are using
this problem file, correct ?

So if we are recompiling, we are more likely to go with the existing
30A and not use VARLEN.

As far as saving DASD space, I believe it would be trivial, as the
detail file with the field BOL is only 2.2 GB ( 1.4 mill records ),
and there are other files with BOL scattered throughout the module in
question. But the space savings of 5A ( actually 5A - 2A for LEN ) is
nominal.

So I assume that if we really wanted to gain any advantage, it would
be to convert the entire system to use the VARLEN(15).

And in actuality, I believe that if we defined the system using SQL
Tables and Views instead of DDS, then we would likely gain more in CPU
savings than anything we might achieve with database field sizes.


John Voris
Crown Americas LLC

--
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.







Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot 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 here. If you have questions about this, please contact