Choosing efficient data types
Choosing the appropriate data type
and PICTURE
clause can produce more efficient code,
as can avoiding USAGE DISPLAY
and USAGE
NATIONAL
data items in areas that are heavily used for
computations.
About this task
Making a data item too large can reduce performance, but a data item whose length is a small power of 2 bytes (1, 2, 4, 8 or 16), and which is aligned on a power of 2-byte boundary matching its size can usually be initialized and moved more quickly and with fewer instructions than one with an odd length or alignment.
Arithmetic is faster with binary than with packed-decimal, which is faster than zoned-decimal or DISPLAY, which is faster than national-decimal.
Options that affect types can also affect performance. For
example, FLOAT(BE)
is more expensive than
FLOAT(NATIVE)
.
Consistent data types can reduce the need for conversions during operations on data items. You can also improve program performance by carefully determining when to use fixed-point and floating-point data types.