You are on page 1of 96

MK


For UNIX

MK in the Informix Environment


Version8.40212
Copyright © 2003 by SSA Global Technologies, Inc.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any
way or by any means, including, without limitation, photocopying or recording, without the prior written consent of
SSA Global Technologies, Inc.
Important Notices
The material contained in this publication (including any supplementary information) constitutes and contains
confidential and proprietary information of SSA Global Technologies, Inc.
By gaining access to the attached, you acknowledge and agree that the material (including any modification,
translation or adaptation of the material) and all copyright, trade secrets and all other right, title and interest therein,
are the sole property of SSA Global Technologies, Inc. and that you shall not gain right, title or interest in the material
(including any modification, translation or adaptation of the material) by virtue of your review thereof other than the
non-exclusive right to use the material solely in connection with and the furtherance of your license and use of
software made available to your company from SSA Global Technologies, Inc. pursuant to a separate agreement
(“Purpose”).
In addition, by accessing the enclosed material, you acknowledge and agree that you are required to maintain such
material in strict confidence and that your use of such material is limited to the Purpose described above.
Although SSA Global Technologies, Inc. has taken due care to ensure that the material included in this publication is
accurate and complete, SSA Global Technologies, Inc. cannot warrant that the information contained in this
publication is complete, does not contain typographical or other errors, or will meet your specific requirements. As
such, SSA Global Technologies, Inc. does not assume and hereby disclaims all liability, consequential or otherwise,
for any loss or damage to any person or entity which is caused by or relates to errors or omissions in this publication
(including any supplementary information), whether such errors or omissions result from negligence, accident or any
other cause.
Trademark Acknowledgements
SSA GT and SSA Global Technologies are trademarks of SSA Global Technologies, Inc. in the United States and/or
other countries.
UNIX is a registered trademark of The Open Group in the United States and/or other countries.
Informix is a registered trademark of IBM Corporation in the United States and/or other countries.
All other company, product, trade or service names referenced may be registered trademarks or trademarks of their
respective owners.
Contents

Chapter 1: Introduction
About This Guide ............................................................................ 1–1
Installation Requirements .................................................................... 1–4
About the Informix Database Driver ........................................................... 1–5

Chapter 2: Configuring Informix For MK


Introduction ................................................................................. 2–1
Installing the Informix Database .............................................................. 2–2
Preparing the Informix Environment .......................................................... 2–4
Installing MK................................................................................ 2–8
Creating the Database for MK ................................................................. 2–9
Installing the Informix Database Driver ....................................................... 2–10

Chapter 3: Setting Up MK For Informix


Introduction ................................................................................. 3–1
Defining the Database in MK ................................................................. 3–2
Linking Companies to Informix ............................................................... 3–3

Chapter 4: Maintaining Driver Files


Overview ................................................................................... 4–1
User File .................................................................................... 4–2
Group File .................................................................................. 4–3
Storage File ................................................................................. 4–4
User Administration Procedures .............................................................. 4–6
Defining Table Storage ....................................................................... 4–9
Maintenance Tools .......................................................................... 4–12

Contents iii
Chapter 5: Mapping MK to Informix
Introduction ................................................................................ 5–1
Table Naming Convention ................................................................... 5–2
Mapping Columns .......................................................................... 5–3
Mapping Indexes............................................................................ 5–4
Data Types ................................................................................. 5–6

Chapter 6: Tuning
Overview ................................................................................... 6–1
Testing Performance ......................................................................... 6–2
Adjusting Parameters ........................................................................ 6–3

Chapter 7: Troubleshooting
Overview ................................................................................... 7–1
Error Mapping and Reporting ................................................................ 7–2
Database Errors ............................................................................. 7–3
Tracing ..................................................................................... 7–6
Database Limitations ........................................................................ 7–7

Appendix A: Files and Executables


Executables ................................................................................. A–1
Driver Files ................................................................................. A–2

Appendix B: Determining Table Space


Introduction ................................................................................ B–1
Changing Extent Size ........................................................................ B–2
Estimating Table Space ...................................................................... B–3

iv MK in the Informix Environment


Chapter

Introduction
1

About This Guide


This guide provides information specific to the Informix database driver for
MK. The Informix database driver serves as the connecting layer between MK
and the Informix database.

This guide describes the installation and maintenance of the Informix database
driver and provides guidelines for using MK in an Informix environment. This
guide does not provide information about Informix database administration or
database management. Refer to your Informix documentation for that
information.

Intended Audience

This guide is intended for system administrators and system programmers who
are responsible for installing and maintaining the Informix database, the
Informix database driver, and MK. Before using this guide, you should be
familiar with the following:
■ Operating system and common commands
■ System administration tools
■ Informix tools and RDBMS and Informix documentation
■ Structured Query Language (SQL)
■ MK concepts (such as users, companies, and so forth)

Introduction 1–1
About This Guide

In addition, you should understand how Informix handles the following:


■ Transaction management
■ Logging
■ Isolation and locking
■ Security
■ Temporary and external tables
■ Indexing
■ Shared memory
■ Disk mirroring
■ Statistical information (update statistics)

How This Guide Is Organized

The information in this book is organized as follows:


■ Chapter 1, Introduction, describes the purpose of this guide, what you should
know before getting started, and which additional documents you should
reference. It also provides a brief overview of the Informix database driver.
■ Chapter 2, Configuring Informix for MK, recommends Informix parameters
settings, describes how to define Informix environment variables, and
explains how to install the Informix database driver.
■ Chapter 3, Using MK with Informix, describes how to add the Informix
database and link to companies within MK.
■ Chapter 4, Maintaining Driver Files, describes files that allow users to access
MK and describes the tools available to maintain those files.
■ Chapter 5, Tuning, provides methods of maximizing Informix performance
for MK.
■ Appendix A, Files and Executables, describes the various executables and
files required by the Informix driver.

1–2 MK in the Informix Environment


About This Guide

Additional References

Related documentation is listed below:


■ Informix Installation Guide
■ Informix Administrator’s Guide
■ Informix Guide to SQL
■ MK Installation and Upgrade Guide
■ MK System Administrator's Guide
■ Hardware and operating system documentation

Introduction 1–3
Installation Requirements

Installation Requirements
You must install the Informix database before installing MK. Refer to the
Informix Installation Guide for information on installing the Informix database.

Refer to Chapter 2, “Configuring Informix for MK” for information on


configuring the Informix database for MK.

1–4 MK in the Informix Environment


About the Informix Database Driver

About the Informix Database Driver


Using MK in an Informix environment involves a communication layer referred
to as the database driver. The database driver is designed to meet the specific
needs of a particular database management system, so that the MK application
can operate in the same manner regardless of the database environment. To this
end, the driver allows MK to access data stored in an Informix database.

The MK shell surrounds or insulates the MK application. It is responsible for


communication with the operating system, MK user interface driver, and
database driver.

The relationship between Informix and MK is depicted in the following diagram:

MK Shell

Database Driver

I-Record SQL

Informix
Database

The database interface is implemented using client/server architecture. The MK


shell, on behalf of the application program, acts as a client and passes data
requests to the Informix database driver. The driver then interacts with the
Informix database and passes the fetched data back to the client, the MK shell,
which then returns the data to the application program.

Introduction 1–5
About the Informix Database Driver

How the Driver Works

When MK wants to perform an action on a table, it finds out which database is


used for that table. This table and database information is stored in the file
$BSE/lib/tabledef5.0. If the table is stored in an Informix database, the Informix
driver is started.

Embedded SQL

The Informix driver uses Embedded SQL (also known as ESQL) to communicate
with the Informix database. ESQL embeds SQL statements into the Informix
driver host language, which is C. You can mix ESQL statements with other host
language statements, using the host variables to represent many of the database
manipulation elements. An important feature of ESQL is that it allows
generation of SQL statements at runtime. This is called dynamic SQL.

Dynamic SQL

Dynamic SQL is used to perform database actions. For example, when you
request an action to read, insert, or update a row, the database driver generates
an SQL statement and executes the statement with any input parameters.

If the execution is successful, the driver passes the results and requested data
back to MK. If the operation fails, an error code is generated and passed back to
MK.

1–6 MK in the Informix Environment


About the Informix Database Driver

Informix Data Organization

Informix does its own disk management and does not use the UNIX file system.
Therefore, only Informix knows and manages its inner data structures and UNIX
is not aware of Informix structures. The basic units of internal data organization
are described in the following table:

Unit Description
pages A page is the basic unit of data access used by Informix.
The size of a page depends on the system hardware
configuration and is fixed for an installation.
extents The extent is a collection of physically contiguous pages
that contain data or index information for a single table.
tblspace The tblspace is a logical grouping of extents; it contains
information for a single table and its associated indexes.
chunks Chunks are a major unit of physical space. They are
either raw devices, parts of raw devices, or UNIX files.
Chunks reserve space for databases.
dbspaces A dbspace is a collection of chunks dedicated to the
storage of databases. A single dbspace can contain all
or part of one or more databases, each of which may
contain many tables and associated indexes.
blobspace A blobspace is composes of one or more chunks
dedicated to storing BLOB data types, such as byte and
text. Blobspaces are often used to store images and
multimedia application information.

Logging

Informix uses logging to implement transaction management and ensure data


integrity. To take advantage of this facility, either the database must be created
with logging or logging must be turned on by the database administrator after
the database is created. (You can, however, create tables without logging.)

The Informix driver creates all tables with logging, except for temporary tables,
which are created without logging.

Introduction 1–7
About the Informix Database Driver

Locking

The default isolation level, or the degree of concurrent data access, used by the
Informix driver during data retrieval is committed to read. For updates and
deletes, the row is locked exclusively until the end of the transaction.

Refer to Chapter 7, “Troubleshooting” for more information about the internal


implementation of locks for updates and deletes and how this affects the
Informix driver.

Security

The Informix driver supports only MODE-ANSI databases (always created with
logging). In MODE-ANSI databases, when a table is created, no user other than
the table owner has any table privileges, unless explicitly granted. However, the
Informix driver provides the ability to organize users into groups. Each user can
have private tables and each group can have group tables. For private tables, no
user other than the table owner has any privileges on the table. For group tables,
the group is the table owner and all users within the group have all table
privileges.

For every group, a database is created with the same name as the group name.
All group tables for that group are created in this database. All private tables
belonging to users in the group are also created in the same database.

Informix does not allow you to grant table privileges on temporary tables.
Therefore, temporary tables cannot be used as group tables.

Key Driver Files

In addition to the files Informix requires, an MK installation uses several key files
to manage access to the database. The following table describes these files:

Key File Description


inf_users Contains information about all MK users who are going to
access the Informix driver.
inf_groups Defines groups of MK users and contains all Informix
database names accessible by MK.
inf_storage Describes database storage specifications for MK tables and
indexes.

These files are discussed in more detail in Chapter 5, “Maintaining Driver Files.”

1–8 MK in the Informix Environment


About the Informix Database Driver

In addition, MK uses the files below to link tables to a particular database driver
and identify the communication protocol to be used between the shell and the
driver:

Key File Description


tabledef6.0 Since MK can use multiple database systems, a table can
exist in any one of the systems. This file identifies the type
of the driver to use for accessing a table, plus other driver
parameters.
ipc_info This file defines the UNIX path name for various driver
executables and the protocols used for communication
between the client and driver process.

The following diagram illustrates how these files work with MK.

tabledef6.0
inf_users ipc_info
Informix inf_groups MK
Database inf_storage

Specific to the Not


Informix Driver Database
Specific

Refer to Appendix A, “Files and Executables” and to the System Administrator’s


Guide for more information about these files.

Introduction 1–9
Chapter

Configuring Informix For MK


2

Introduction ................................................................................. 2–1


Installing the Informix Database .............................................................. 2–2
Suggested Informix Parameters ........................................................... 2–2
Preparing the Informix Environment .......................................................... 2–4
Disk Requirements ....................................................................... 2–4
Moving Physical and Logical Logs ......................................................... 2–5
Preparing UNIX ......................................................................... 2–6
Tuning Kernel Parameters ................................................................ 2–6
Preparing Space for Data Storage .......................................................... 2–7
Configuring Informix..................................................................... 2–7
Installing MK................................................................................ 2–8
Creating the Database for MK ................................................................. 2–9
Installing the Informix Database Driver ....................................................... 2–10
Mapping Users to Groups ............................................................... 2–11
Verifying the Informix Installation ........................................................ 2–12

Configuring Informix For MK 2–i


Chapter

Configuring Informix For MK


2

Introduction
In general, installing MK in an Informix environment involves the following
steps:
1. Installing Informix database software
2. Configuring Informix for MK
3. Initializing the Informix database driver
4. Creating MK tables and companies

This chapter covers the first two steps and should be used with the information
found in the MK Installation and Upgrade Guide and in the Informix Installation
Guide. Step three is discussed in Chapter 3.

Configuring Informix For MK 2–1


Installing the Informix Database

Installing the Informix Database


Before installing the Informix database driver, you must install the Informix
database. If Informix is already installed on your system, make sure that your
configuration complies with the recommendations in this section.

Using the standard Informix installation instructions, install the Informix


database. Make a note of the setting of INFORMIXDIR. During the installation,
you will need to set values for a number of parameters.

Suggested Informix Parameters

Use the following table to set the default values for Informix installation
parameters. You can change the parameter values by editing the ONCONFIG file
manually and restarting Informix.

Important! Do not run the Parameter-Initialize option after initializing the database
unless you are prepared to lose all current data.

Parameter Description/Recommended Setting


PageSize Display-only field, since the value is the fixed page size for
your system.
Mirror If you enter Y, you do not turn mirroring on; you simply
initialize the system to allow mirroring and allocate some
additional data structures.
Sys.Log File Specify name of the UNIX file to contain Informix system
messages about system status changes, I/O errors, and
other events relating to the system.
System Msgs. Specify a second device to record database events.
Tape Dev. Specify the tape device to be used for system archives.
Block Size Specify tape block size to be used for system archives.
Total Tape Size Specify how much data can be written to each tape in a
system archive.
Log Tape Dev. Specify tape device to be used for logical log file archives.
Block Size Specify tape block size to be used for logical log file
archives.
Total Tape Size Specify how much data can be written to each tape in a
logical log file archive.
Root Name name of the root dbspace for the system. Default is
rootdbs.

2–2 MK in the Informix Environment


Installing the Informix Database

Parameter Description/Recommended Setting


Root Size Size (kb) of the primary chunk assigned to the root
dbspace.
Primary Path Device name of the primary chunk of root dbspace.
Offset Offset into the device or file where the primary chunk of
the root dbspace starts. If your root dbspace is a raw
device, it is highly recommended that you provide some
offset into the device to avoid control information from
being overwritten.
Mirror Path Full path name of the device to be used as a mirror chunk
for the root dbspace. Informix requires that the mirror
device must be the same size as the chunk it is mirroring.
Offset This offset field refers to the offset into the mirror device.
Phy. Log Size The size in kb of the physical log to be created in root
dbspace for recovery purposes. Generally, the size of a
physical log is about twice the size of a single logical log
file.
Log.Log Size This is the size of each logical log file created for
transaction logging. it is important to remember that this
value cannot be changed without reinitialization.
Number of Logical This specifies how many logical logs will be created in
Logs root dbspace at initialization. More logs can be added at a
later time, but there must be a minimum of three on the
system.

After installing and working with MK, you may need to adjust some of these
parameters to fit the specific requirements of your environment.

Configuring Informix For MK 2–3


Preparing the Informix Environment

Preparing the Informix Environment


After you install Informix, you need to configure it for MK. This section
describes what you need to do, including:
■ Disk requirements
■ Moving physical and logical logs
■ Preparing UNIX
■ Tuning kernel parameters
■ Preparing space for data storage
■ Configuring Informix

Disk Requirements

In addition to the MK requirements described in the MK Installation and Upgrade


Guide, consider the following requirements when using the Informix database:

Requirement Approximate Disk Space


Empty and test databases 100 Mb (each)
Informix database 20 Mb

2–4 MK in the Informix Environment


Preparing the Informix Environment

If you have multiple disks, you can reduce input/output bottlenecks by careful
placement of the software. The following diagram illustrates some possible
configurations:

Disk 1 Disk 2
2 Disk
System MK Users

UNIX Data

Informix

Disk 1 Disk 2 Disk 3


3 Disk
System MK Informix Users

UNIX Data

Disk 1 Disk 2 Disk 3 Disk 4


4 Disk
System UNIX MK Informix Data

Users

Disk 1 Disk 2 Disk 3 Disk 4 Disk 5


5 Disk
System UNIX MK Informix Data Checkpoints

Users

Moving Physical and Logical Logs

When Informix is initialized, the physical and logical logs reside in the root
dbspace. These logs should be moved to another dbspace before installing MK.

Create a separate dbspace for the physical and logical logs (for example, llogbds
and plogdbs), preferably on different devices and then move the logs to an
appropriate dbspace. This will enhance performance and provide better
safekeeping in case of media failure. Refer to the Informix Administrator's Guide
for more information.

Configuring Informix For MK 2–5


Preparing the Informix Environment

Preparing UNIX

There are some UNIX steps that you must take to prepare the operating system
to receive Informix. These steps are:
1. Log in as root.
2. Set terminal erase key to Ctrl-h:
stty erase <ctrl>h
3. Add a new group called informix in the group file /etc/group with a group
ID greater than or equal to 100 but less than 300, and assign the user
informix to this group:
informix:*:150:informix
4. Create the Informix user for database administration.
5. Create the directory to contain the Informix database:
cd <directory specification>
mkdir informix
6. Assign the environment variables INFORMIXDIR and PATH to point to
this new directory.

Tuning Kernel Parameters

Adjust kernel parameters, keeping the following in mind (parameter names may
vary depending on whether the kernel is System V or BSD):
■ SHMMAX*SHMSEG = how much shared memory Informix can use
■ SHMMAX*SHMMNI = how much shared memory in your UNIX system
■ SEMMNI*SEMMSL = how many semaphores Informix can access; these
values should reflect maximum number of Informix users

2–6 MK in the Informix Environment


Preparing the Informix Environment

Preparing Space for Data Storage

To prepare space for data storage, you can use either cooked files or raw devices.
The steps to do both are shown below.

⇒ To create a cooked file:


Use the following:
cat /dev/null > file-name
chmod 660 file-name
chgrp informix file-name
chown informix file-name

⇒ To create a raw device:


1. Create an unmounted piece of disk.
2. Use links (ln) to assign a more descriptive name to the device. This also
makes substituting devices for recovery purposes easier.
3. Set ownership and permissions as follows:
chmod 660 device-name
chgrp informix device-name
chown informix device-name

Configuring Informix

⇒ To configure Informix:
1. Set up the following environment variables:
INFORMIXDIR
INFORMIXSERVER

2. Log in as user informix.


3. Type env to check that all environment variables are set.
4. Invoke the onmonitor utility to initialize Informix and select Parameters and
Initialize options.
5. Set maximum numbers as follows (these are the recommended minimum):
MAX# locks = 8000
MAX# buffer = 800

Configuring Informix For MK 2–7


Installing MK

Installing MK
After you prepare the Informix environment, you can install MK by running the
MK installation program, mk.install6.0. Refer to the MK Installation and Upgrade
Guide for complete instructions about the installation procedure.

2–8 MK in the Informix Environment


Creating the Database for MK

Creating the Database for MK


For an initial installation, all users use one database. The database administrator
of this database should be added to the Informix group that has the same name
as the database. (By default, informix is the DBA of all Informix databases; all
other users must be associated with a specific group.)

This section summarizes the steps you need to take before installing the MK
Informix database driver:
1. Configure the installation.
2. Create a UNIX login for mk.
The user mk is the Database Administrator (DBA) of the database where
your MK tables are stored. Add mk to the bsp group at the UNIX level. For
example:
mk::125:125:<home directory>:/bin/ksh

3. Add the following variables to the user mk environment:


INFORMIXDIR=<path of directory containing Informix>
export INFORMIXDIR
PATH=$PATH:$INFORMIXDIR/bin
export PATH

4. Create the Informix database mk (still logged on as informix), using either


the Informix tool dbaccess or the MK Informix installation utility
inf7_inst6.0.

Configuring Informix For MK 2–9


Installing the Informix Database Driver

Installing the Informix Database Driver


The mk.install6.0 program installs the Informix drivers and then starts a UNIX
shell. Within this shell, you can run the driver initialization program,
inf7_inst6.0, to set up the Informix database for MK.
To initialize MK for Informix, run inf7_inst60. This script does the following:
■ Creates the inf_groups file and adds the initial group (mk) to it.
■ Creates a dbspace for group database.
■ Defines the name of the initial group and grants DBA permission for that
database.
■ Creates the inf_users file and adds the users root and bsp to the initial group.
■ Creates the inf_storage file and adds default table and index entries to
storage file.

⇒ To install the driver:


1. Log in as informix. Do not use the su command.
Note: On some System V-based operating systems, you might need to use
the command newgrp informix to change your primary group after logging
in.
2. Run the inf7_inst6.0 script. Keep the following in mind:
■ When Informix is initialized, it has a single (root) dbspace. The group
database(s) should never be created in root dbspace. Therefore, you
should create a dbspace for the group database. For example, create a
dbspace named "mkdbs" for dabase "mk."
■ The maximum characters allowed for the dbspace name is eighteen
characters.
■ The dbspace path is the location of the file that will be used for creating
dbspace. This can be either a raw device or a plain UNIX file. If you are
using raw device, this should already be created at this point. If you are
using a plain UNIX file, inf7_inst6.0 will create the file if it does not exist.
You must create the default directory for the file
($INFORMIXDIR/dbspace).
■ If the program encounters any error in creating dbspace, it displays the
error message and exits.
■ Accept the default storage structures. These parameters are used when
creating the tables for the demo companies.
3. If you want to modify these settings, you should modify the file
$BSE/lib/informix/inf_storage before creating the tables for your main
companies.
Note: We recommend that you specify the dbspace name in the
$BSE/lib/informix/inf_storage file.

2–10 MK in the Informix Environment


Installing the Informix Database Driver

Mapping Users to Groups

⇒ To add your users to the mk database:


1. Log on as informix.
2. Run the Informix driver administration utility, inf7_admin6.0.
3. If you haven't already done so (while running inf7_inst6.0), authorize users
mk, root, and bsp to access the Informix database:
■ Select the User Administration option.
■ Select the option to add users.
■ Enter the group database name (for example, mk).
■ Enter the user name.
■ Add the next two users. After you have added the three mandatory
users, you can continue adding MK user names, if you know them.
4. Select the Informix Maintenance option.
■ Enter a valid database name.
■ Choose the option to Run ISQL to access Informix SQL. Select the Query
Language option.
■ For the user mk, grant dba permission for the database:
grant dba to "mk";
commit work;

■ For users root and bsp and any other users entered in the previous step,
grant resource permissions to the database:
grant resource to "root";
grant resource to "bsp";
grant resource to "user1";
grant resource to "user2"'
commit work;

Continue granting permission to all the Informix users for this database.

Configuring Informix For MK 2–11


Installing the Informix Database Driver

Verifying the Informix Installation

⇒ To verify that the Informix database has been correctly installed:


1. Log in as informix or use the su command to temporarily give you the
privileges of an Informix super user:
su informix

2. Start the dbacces utility:


dbaccess

3. Choose the Database option.


4. Enter a valid database name. Success execution of this statement verifies:
■ Informix has been installed and the database is set up properly
■ The Informix executables are in your path
■ $INFORMIXDIR is set
■ The Informix database servers are running
5. Verify that the users mk, bsp, and root exist as Informix users. Within the
dbaccess utility, select Query Language.
6. Enter the following query statement:
Select * from sysusers;

7. Exit the dbaccess utility and return to the previous shell.


8. Use the su command to become the user root:
su root

9. Change to the directory $BSE/bin.


cd $BSE/bin

10. Change the owner and permissions on the file inf7_exec6.0 (this must be
done after MK is installed because the last step of the installation process
changes the file ownership to bsp).
chown root inf7_exec6.0
chmod 4750 inf7_exec6.0

11. Verify the file permissions you have set. The permissions should be:
-rwsr-x--- 1 root bsp (size) (date) inf7exec6.0

12. Add the user informix to the group informix in the file /etc/groups (if you
haven't already done so).
13. Exit the shell started by su.
exit

2–12 MK in the Informix Environment


Chapter

Setting Up MK For Informix


3

Introduction ................................................................................. 3–1


Defining the Database in MK ................................................................. 3–2
Linking Companies to Informix ............................................................... 3–3

Setting Up MK For Informix 3–i


Chapter

Setting Up MK For Informix


3

Introduction
After you install the Informix database and the Informix driver, you need to
modify certain MK data before you can begin using any Informix tables. You
need to:
■ Add Informix as a database in the Maintain Database Definitions
(ttaad4110m000) session.
■ Create at least one company with the Maintain Companies (ttaad1100m000)
session.
■ Link the company to the Informix database with the Assign Tables to
Databases (ttaad4111m000) session.
■ Run the Convert to Runtime Data Dictionary (ttaad4200m000) session.

After you have completed these steps, you can post data to the Informix
database.

Setting Up MK For Informix 3–1


Defining the Database in MK

Defining the Database in MK


After you have installed both Informix and MK, you need to define the database
within MK.

⇒ To add Informix as an MK database:


1. Run the Maintain Database Definitions (ttaad4110m000) session:

2. Identify the database.


3. In the Parameter field, specify the INFORMIXDIR environment variable and
its value.
Specify other environment variables that you want defined when the driver
starts by adding them to the Parameter field. Use a comma (,) as a separator
with no spaces between the fields and commas. The environment variables
you might define include:

Variable Description
SQLLOG Allows you to log various commands executed by the
driver in a trace file in the working directory of the user.
For more information, refer to Chapter 7,
"Troubleshooting."
INFPROF Allows you to profile database actions. Set to a number
of seconds. All SELECT sections taking longer than this
value are written to a file called infprof in the directory
where the driver was started. For more information,
refer to Chapter 6, "Tuning."

3–2 MK in the Informix Environment


Linking Companies to Informix

Linking Companies to Informix


⇒ To create new companies or convert existing companies to Informix:
1. Run the Maintain Companies (ttaad1100m000) session.

Make sure the company you want to create has been entered in the company
tables. If necessary, add the company.
2. If Informix has not been added already, add Informix as a database in the
Maintain Database Definitions (ttaad4110m000) session. Refer to the
previous section, Defining the Database in MK.
3. Run the Assign Tables to Databases (ttaad4111m000) session to specify that
the database for the company is Informix.

Setting Up MK For Informix 3–3


Linking Companies to Informix

Enter values in the following fields:


■ All Comp — Enter No.
■ Company — Enter the Informix company number.
■ Table Selection — Enter All other tabl.
4. Run the Convert to Runtime Data Dictionary (ttaad4200m000) session. This
produces corresponding entries in $BSE/lib/tabledef6.0.

You are now ready to post data to the Informix database.

3–4 MK in the Informix Environment


Chapter

Maintaining Driver Files


4

Overview ................................................................................... 4–1


User File .................................................................................... 4–2
Group File .................................................................................. 4–3
Storage File ................................................................................. 4–4
User Administration Procedures .............................................................. 4–6
Adding a Group ......................................................................... 4–6
Adding a User to a Group ................................................................ 4–7
Dropping a User from a Group ............................................................ 4–7
Dropping a Group ....................................................................... 4–8
Defining Table Storage ....................................................................... 4–9
Multiple Specifications ................................................................... 4–9
Parameters ............................................................................. 4–10
Recommendations ...................................................................... 4–11
Maintenance Tools .......................................................................... 4–12
MK Sessions ............................................................................ 4–12
Using the inf7_admin6.0 Tool ............................................................ 4–13

Maintaining Driver Files 4–i


Chapter

Maintaining Driver Files


4

Overview
There are three files used to assign access privileges to MK driver users and to
link MK driver users to Informix databases:
■ inf_users (user file)
■ inf_groups (group file)
■ inf_storage (storage file)

These files reside in $BSE/lib/informix and can be created and maintained using
MK optimization sessions, the script inf7__admin6.0, or the executable
inf7_inst6.0.

This chapter describes the content and structure of these files. It also describes
how to use the database administration tools to maintain the files.

Maintaining Driver Files 4–1


User File

User File
The user file contains information about all MK users who can access Informix
tables. Each line in this file consists of four fields, which are separated by a colon
(:). The format is as follows:

<MK user>:<Informix user>:<encrypted password>:<group>

For example:

bsp:bsp:ufFPd$d#Xyyp[95 bp]/*'*/<D/+]+L0:mk

Variable Value
MK user Name by which the user is known to MK. This
should be a valid login name and cannot be
Informix.
Informix user User name that is accessing the database. This is
usually the same as the MK user name.
Encrypted password User's encrypted password for the database. The
Informix driver does not use this password; therefore,
you do not need to assign one when creating a user
with the maintenance utility. The utility assigns a
dummy password.
Group name Group to which the user belongs—it is mk for all
users.

Note: Whenever you add or change user information, you must first do so in
the Informix database, and then use inf7_admin6.0 or the MK maintenance
sessions to modify the user file for the driver.

4–2 MK in the Informix Environment


Group File

Group File
MK users are mapped to Informix databases or groups. Each group can have
many users. For every group, a database is created with the same name as the
group name. An MK Informix group is the same as an Informix database;
therefore, the group file contains information about Informix databases where
MK can find the Informix tables. This information is stored in
$BSE/lib/informix/inf_groups. Each line in this file is made up of two fields,
separated by a colon (:). The format is as follows:

<group name>:<group password>

Variable Value
Group name Group name should be mk.
Group password Group mk's encrypted password. This password is not used by
Informix; therefore, you don't have to assign one when creating a
user with the maintenance utility.

Maintaining Driver Files 4–3


Storage File

Storage File
The storage file contains information about the storage structure of the Informix
tables and specifies various object parameters. The Informix driver refers to this
file when creating objects and executing queries. The storage information is held
in $BSE/lib/informix/inf_storage. Each line in this file consists of seven fields,
separated by a colon (:). The format is as follows:

[(user)] <table_name>:<company number>:<entry type>:<owner


type>:<index optimization level>:<refresh time>:[<storage>]

Note: Fields in square brackets [ ] are optional; you can use wildcards for the
table name and the company name.

Variable Value
User You can link table information to a specific user or several users by indicating
the user's login name in braces ({}). Specifications then apply to the defined
user only. Separate multiple users by a comma. If you do not specify a user,
the information applies to all users.
Table_name Specifies the name of the MK table. This is a combination of the package,
module, and table name. Available options are:
■ Wildcard (*) to specify all tables in all modules.
■ All tables in a module, specified by the five-letter package/module code
(tfacp, tdsls, and so forth).
■ Module code and specific table number (tiitm005, tccom001, and so
forth).
Company number Specifies the company number. Use a wildcard (*) to specify all companies or
you can one company or several companies separated by commas.
Entry type Indicates whether the line relates to a table or index:
■ Wildcard (*) to specify table and all indexes
■ Table only (T)
■ All indexes of the table (I)
■ One or more indexes of the table (In where n is the number of the index.
You can specify a list of indexes, separated by commas.
Owner type Specifies whether the table belongs to a single person or to a group. The
following options are available:
■ Private (the table can be accessed only by its owner)
■ Group (the table can be accessed by the entire group)
This relates only to tables; when used for an index, it is ignored.

4–4 MK in the Informix Environment


Storage File

Variable Value
Index optimization Specifies index optimization level. Specify 0 for no optimization; specify 1
for optimization using one hash column.
If you do not specify an optimization level for an index, the default is taken
from the corresponding table entry.
Refresh time By setting a refresh time (in seconds), you determine the validity period of a
table's data set. The default value is 0. You can set refresh time only for
tables; it is ignored for indexes.
Storage Specifies the parameters to be used when creating tables. See Defining Table
Storage Parameters later in this chapter for more information.

Examples
{acp}tiitm001:*:T:private:1:5:DBSPACE rootdb INITIAL 1024 LOCK row

{acp}tiitm001:000:I1,I2,I3::1::

*:*:T:group:1:10:DBSPACE rootdb INITIAL 2048 NEXT 128

*:*:I1,I2,I3::1::

Maintaining Driver Files 4–5


User Administration Procedures

User Administration Procedures


MK users are divided into different groups in Informix. Therefore, whenever
you add a user, you must also specify the Informix group to which the user
belongs. Each group can have many users, but a user can be associated with
only one group at a time.

For security reasons, only the Informix database administrator (informix) and
root are allowed to perform user administration tasks. This section describes the
basic user administration tasks. There are several tools available to perform
these tasks; these are described later in this chapter.

Adding a Group

At installation, the utility inf7_inst6.0 lets you add an initial group, dbspace,
database, and the users root and bsp. You can use the Informix tools onmonitor
and dbaccess to add dbspaces and databases, and inf7_admin6.0 to add users
and groups.

⇒ To add a new group for MK to access:


1. Create a UNIX login for the group name.
2. Log in as informix.
3. Create a new dbspace for the group database, if needed.
4. Create a MODE ANSI database with the same name as the group name.
5. Grant DBA permission to the group.
6. Grant permission to root so that root can also do user administration.
7. Log in as informix or root.
8. Run inf7_admin6.0.
9. Add the group using the Add Group option under User Administration.

4–6 MK in the Informix Environment


User Administration Procedures

Adding a User to a Group

⇒ To add a user to a group:


1. Create a UNIX login for the MK user.
2. Log in as informix or root.
3. Run inf7_admin6.0.
4. Add the MK user using the Add User option under User Administration.
5. Verify using the List Users and List Groups options.
6. Log in as informix or group user (DBA).
7. Run inf7_admin6.0.
8. Run ISQL using the Run ISQL option under Informix Maintenance.
9. Make the group database current.
10. Grant resource permission to the user.
11. Verify that database privileges are properly granted, using the List Database
users option under Informix Information.

Dropping a User from a Group

⇒ To drop a user from a group:


1. Log in as informix or root.
2. Run inf7_admin6.0.
3. Drop the user using the Drop User option under User Administration.
4. Verify using the List Users and List Groups options.
5. Log in as informix or the group user (DBA).
6. Run inf7_admin6.0.
7. Run ISQL using the Run ISQL option under Informix Maintenance.
8. Revoke the resource privilege and connect privilege from the MK user.
9. Verify that database privileges have been properly revoked using the List
Database Privileges option under Informix Information.

Maintaining Driver Files 4–7


User Administration Procedures

Dropping a Group

⇒ To drop a group:
1. Log in as informix or root.
2. Run inf7_admin6.0.
3. Drop the group using the Drop Group option under User Administration.
4. Verify using the List Groups option.

After dropping a group, you do not need to drop the group database. It is the
database administrator's decision whether to drop the database; however, you
should be extremely cautious about dropping the database since you might want
to save some of the data stored in that database. In general, it is best to keep the
database unless you experience security or disk space problems. If you do
decide to drop the database, use the following procedure:
1. Run ISQL using the Run ISQL option under Informix Maintenance.
2. Drop the database.

4–8 MK in the Informix Environment


Defining Table Storage

Defining Table Storage


The storage file inf_storage contains the table and index specifications to use
when creating tables. This section provides guidelines you should keep in mind
when editing the storage file. For information about the tools used to edit this
file, see the Maintenance Tools section later in this chapter.

Multiple Specifications

When putting the table or index specifications in the storage file, be careful not to
create multiple specifications that refer to the same group table or index. For
example, if three MK users (alan, kent, bob) are in the group finance and the
storage file contains the following entries:
{alan}ttaad099:000:T:group:0:0:DBSPACE db1 LOCK row NEXT 128
{kent}ttaad099:000:T:group:1:0:DBSPACE db2 LOCK page NEXT 256
{bob}ttaad099:000:T:group:1:5:DBSPACE db3 NEXT 528
*:*:I::::

This file is valid from the syntax point of view; however, since alan, kent, and
bob are in the same group, they refer to the same group table with different
conflicting specifications. Because the specifications are different, this is what
might happen. If alan creates a table, the driver will create the table without
hash columns. If kent or bob attempt to access the table, the Informix driver will
assume that there is a single hash column and try to use it in the query. Since the
hash column does not exist, an error will be generated and kent and bob will not
be able to access the table.

You can avoid this problem by creating a common entry for all MK users in the
group. For example:
{alan,kent,bob}ttaad099:000:T:group:1:5:DBSPACE db1 LOCK row NEXT 256

Now there is only one set of specifications for the group table.

Maintaining Driver Files 4–9


Defining Table Storage

Parameters

When defining the storage structure, you can control various parameters for
creating tables. These parameters are optional and are specified using the
following syntax:
[INITIAL n] [NEXT n] [LOCK ( page/row )] [DBSPACE x] [TEMP]

These parameters are described in the following table. For recommendations on


how to set the parameters, see the Recommendations section that follows the
table.

Parameter
Keyword Description
INITIAL Specifies the size (in kilobytes) of the initial extent to be
created when creating the table. The minimum is 4 pages.
This parameter is used when creating the table and cannot be
changed later on. If not specified, the default is 8 pages.
NEXT Specifies the size (in kilobytes) of the next extent to be
allocated for the table. This parameter is used when creating
the table, but can be changed after the table is created. If not
specified, the default is 8 pages.
LOCK Specifies the lock mode to be used while accessing the table.
It can be either page or row. The default is row.
DBSPACE Specifies the name of the dbspace in which the table should
be created. If not specified, the table is created in the dbspace
containing the database.
TEMP Specifies that the table is a temporary table. If created, the
table exists only until the end of the session. Because
Informix does not allow you to grant permissions on
temporary tables, these tables cannot be created as group
tables.

4–10 MK in the Informix Environment


Defining Table Storage

Recommendations

When defining table storage and setting table parameters, keep the following
suggestions in mind:
■ For group objects (tables or indexes), create a single entry for all MK users in
the group. This will avoid conflicts and runtime errors.
■ For security reasons, limit write permission for the storage file.
■ Set index optimization to 1 (single hash column) unless the table is very
small or disk space is critical. Without hash optimization, the query time on
tables will increase.
■ Refresh time depends on how frequently the table data is modified. It
should create a balance between good performance and getting the most
recent data.
Unlike other parameters, which are used only during table creation, refresh
time is set every time the driver is started and when it accesses the table for
the first time. Therefore, after changing refresh time, if a driver is started,
new refresh times will be in effect.
■ If initial extent size and next extent size are not specified, Informix uses a
default of 8 pages. This may be too small for some tables, or tables that are
going to grow significantly in the future. In such cases, use the procedure
described in Appendix C to estimate the correct initial and next extent sizes,
then enter the values for the Initial and Next parameters.
■ Use the lock mode "row" for better concurrency. This is also the default used
by the driver, if none is specified. Lock mode "page" should be used only for
tables that are read-only or rarely modified.
■ If DBSPACE is not specified in the storage file, the table will be created in the
dbspace containing the database. Tables should not be created in the root
dbspace.
■ To change storage file entries after a table is created, use the Alter Table
Parameter option in inf7_admin6.0 (or drop and recreate the table).

Maintaining Driver Files 4–11


Maintenance Tools

Maintenance Tools
You can maintain the user, group, and storage files with a special administration
tool. Depending on the user interface you want to use, you can access different
versions of this tool. To maintain the driver files, you can use any of the
following:
■ MK Informix database maintenance sessions
■ inf7_admin6.0 tool

Note: Before adding groups or users with these tools, they must be defined as
valid UNIX and Informix users.

MK Sessions

As part of its system management functionality, MK provides several sessions


for maintaining database information. To access the administration tools from
within MK, select Maintain Informix Parameters under the Database
Management menu.

From this menu, you can select the appropriate sessions for adding, removing,
and reporting user and group information and for editing and viewing the
storage file. You can also print Informix user, group, and storage information.

4–12 MK in the Informix Environment


Maintenance Tools

Using the inf7_admin6.0 Tool

The maintenance tool, inf7_admin6.0, is a shell script that allows you to maintain
and report user and database information in Informix. Options in the script are
organized as follows:

Option Description
User Administration Options for adding or dropping MK Informix users
and groups
User Information Options for listing the contents of the user, group,
and storage files
Informix Information Options for displaying information about tables and
indexes in a database
Informix Maintenance Options for performing database management tasks
such as checking database catalogs, repairing
indexes, and changing table parameters

The inf7_admin6.0 script is stored in $BSE/bin. Before using this command, the
Informix database should be up and running. If it is installed and operational,
enter inf7_inst6.0 at the operating system prompt to access the Informix
maintenance command. (You are prompted for the BSE environment variable if
it is not already set.)

Maintaining Driver Files 4–13


Maintenance Tools

User Administration

The User Administration area allows you to maintain MK Informix users and
groups. You can select the operation you want to perform.

Option Description
Add user Adds the user to inf_users file and grants the user access to
all group tables. Enter the group and MK user name; this
user name is the same as the Informix user name. After
adding the user, grant resource privilege to the MK user for
the group database using Run ISQL.
Drop user Revokes all privileges to group tables for a user and
automatically deletes the user's line in inf_users. Enter the
MK user name and the group the user belongs to; you
cannot use wildcards. After removing the user, the DBA
should revoke the resource and the connect database level
permissions from the user.
Add group Enables you to create a group (database) by adding the
group to the inf_groups file. Enter the name of the group to
be created. The DBA should also:
■ Create a MODE ANSI database with group name
■ Grant DBA privileges to the group user
■ Grant connect permission to root user
Drop group Deletes a group from the inf_groups file. Enter the name of
the group to be dropped. If applicable, the DBA should
remove the group database and the corresponding UNIX
login.
Exit Exits the maintenance utility.

4–14 MK in the Informix Environment


Maintenance Tools

User Information

The User Information option lets you list the contents of the user file, the group
file, and the storage file. It also provides you with an option to edit the storage
file. You can select the operation you want to perform.

Option Description
List users Lists all users in the inf_users file. For each user, this option
displays the MK name, Informix name, and group.
List groups Lists all groups in the inf_groups file, including each group
name (database) along with a list of users in each group.
List storage Displays the information about a table or index held in the
inf_storage file.
Edit storage Allows you to edit the storage file.
Exit Exits the maintenance utility.

Maintaining Driver Files 4–15


Maintenance Tools

Informix Information

To view Informix-related information about database objects, such as tables or


indexes, you can select the Informix Information option. Because there can be
multiple databases, when you select this option, you need to indicate the
database you want information about. After you select a database, you can select
the option you want to perform. The available options are described in the
following table.

Option Description
Show tables Displays information about tables created in the current
created database. User name and table name are required. You can
also use wildcards.
Show table Shows column information for tables. User name and table
columns name are required. You can also use wildcards.
Show indexes Displays information about indexes on tables created by a
created user in the group. User name and table name are required.
You can also use wildcards. Update statistics is required to
show the latest information.
Show index Shows column information for indexes created by a user
columns (index owner). Since the user name and table name form
part of the index name, these are used to do a wild card
search for the index name. You can also specify an index
number if you want information about a specific index. If
you want to see all indexes created by the user of that table,
enter * for the index number.
Show table space Displays information about space used by tables in the
information database. User name and table name are required. You can
also use wildcards. Update statistics is required to show the
latest information.
Show database Displays the privileges assigned to various users in the
privileges current database. If the generic user public has a privilege,
that entry is highlighted with two asterisks (**).
Show dbspace Displays information about all dbspaces in Informix.
information
Exit Exits the maintenance utility.

4–16 MK in the Informix Environment


Maintenance Tools

Informix Maintenance

You can perform some common database management tasks by selecting the
Informix Maintenance option. Because there can be multiple databases, when
you select the Informix Maintenance option, you need to indicate the database
you want to maintain. Then you can select the option you want to perform. The
available options are described in the following table.

Option Description
Print report for a Prints indexes for a specific database or table within a
tablespace database. The Informix utility oncheck (oncheck -pt) is
used. User name and table name are required.
Print disk utilization Prints a disk utilization report. The Informix utility
report oncheck (oncheck -pt) is used. This report provides
detailed information about different types of pages
used in the table. User name and table name are
required.
Update statistics Updates statistics for tables in the current database.
User name and table name are required. Executing this
activity for a number of tables may take some time.
Run ISQL Runs Interactive SQL. ISQL will not run if Informix is
not up or you are using an unrecognized terminal type.
Note that ISQL is called dbaccess in recent versions of
Informix.
Show error message Displays the message associated with the specified
for SQL or ISAM code error code. Enter the absolute value of the error code.
For example, if the error code is -206, enter 206 to
display the corresponding message.
Alter table parameters Changes the next extent and lock mode for a table
owned by the user running inf7_admin6.0.
Exit Exits the maintenance utility.

Maintaining Driver Files 4–17


Chapter

Mapping MK to Informix
5

Introduction ................................................................................. 5–1


Table Naming Convention .................................................................... 5–2
Mapping Columns ........................................................................... 5–3
Column Name Conventions............................................................... 5–3
Hash Column Name Convention .......................................................... 5–3
Mapping Indexes ............................................................................ 5–4
Field Numbering......................................................................... 5–4
Hash Column Size ....................................................................... 5–5
Data Types .................................................................................. 5–6
Dates ................................................................................... 5–6
Strings .................................................................................. 5–7

Mapping MK to Informix 5–i


Chapter

Mapping MK to Informix
5

Introduction
Before creating tables for MK, you should be familiar with certain MK
requirements. This chapter discusses the mapping between the MK database
dictionary and Informix. This mapping task is handled by the MK Informix
driver and involves:
■ Tables
■ Indexes
■ Columns
■ Data types

MK stores table columns and index information in its data dictionary. The
Informix driver uses this information for various database actions. However, the
Informix driver cannot use this information directly because fields in MK use
certain characters (such as the dot (.)) that are invalid for Informix and some data
types (such as date) are stored differently in MK and Informix.

In order to store and/or write the MK data, the driver maps the information into
a format suitable for Informix. All Informix database actions use this mapped
information.

Mapping MK to Informix 5–1


Table Naming Convention

Table Naming Convention


In MK, every table is identified by a two-character package code, a table name
(comprised of a three-character module code and a three-digit table number) and
a three-digit company number. To be consistent, both MK tables and index
names in Informix use these identifiers.

To comply with MK table naming conventions, Informix table names use the
following naming format:
t<package code><data dictionary table name><3 digit company number>

For example, MK table name tiitm001 with company number 100 has the
corresponding Informix table ttiitm001100. Note that the company number
always contains three digits, using zeros if necessary.

The following table contains examples of MK table names in Informix:

Table Name MK
ttiitm001100 table prefix: t
package code: ti
table: itm001
company number: 100
ttdsls112100 table prefix: t
package code: td
table: sls112
company number: 100

5–2 MK in the Informix Environment


Mapping Columns

Mapping Columns
Each MK data dictionary column has a corresponding Informix column. If an
MK column has a depth greater than one (array), each subsequent depth is a
separate Informix column.

Row ID is used as a pseudo column. It does not exist in the table, but is used
internally, so users will not be aware of its existence.

Column Name Conventions

An Informix column is named by adding the string t_ before the MK data


dictionary column name. For example, if a data dictionary column name is code,
the corresponding Informix column name is t_code.

If a data dictionary field has a depth greater than one, each depth is a separate
Informix column and each Informix column is named using the corresponding
depth. For example, if the MK field ctod has depth 7, there are seven Informix
columns with names t_ctod_1, t_ctod_2, ...t_ctod_7.

Informix does not allow a period (.) as part of a column name. Therefore, if an
MK field name contains a period, the period is replaced by the underscore
character (_) in the corresponding Informix column name.

Hash Column Name Convention

A hash column is created when a table has hash optimization. The hash column
name contains its corresponding index number. When single column index
optimization is used, there is a single hash column per index. The column name
is hash<index number> (for example, hash1, hash2). Thus, hash1 is created for
index 1, and hash2 for index 2.

Mapping MK to Informix 5–3


Mapping Indexes

Mapping Indexes
An Informix index name can contain up to 18 characters. The driver creates the
index name using package code, table name, company number, index number,
index order, and table owner name, according to the following example:
Index name = package code, such as ti
+ table name, such as itm001
+ company number, such as 100
+ index number, such as 2
+ table owner name
Note: If the table owner name is long, it is truncated so that
is does not exceed 18 characters.

The following example shows how an index name, tiitm0011002mk, is created


from these parameters:
■ Package code—ti
■ Table name—itm001
■ Company number—100
■ Index number— 2
■ user — mk

Field Numbering

When an index is created, the field number associated with each field is stored in
memory as part of Informix's index information. If a field having a depth greater
than 1 is part of the index, Informix uses the following logic:
■ A field having a depth of n creates n columns in the Informix table. For
example, if field3 in the data dictionary has a depth of 3, it creates 3 fields in
Informix table — field 3, field 4, and field 5.
■ If this field is part of the index, the index description contains all the
corresponding Informix field numbers; in this example, 3, 4, and 5.
■ The index length includes the length of each of these fields.

When the index is created, for each field number, the corresponding field name is
picked up.

5–4 MK in the Informix Environment


Mapping Indexes

Hash Column Size

If an index is created with single column optimization, an additional column is


added when the table is created. The size of this hash column depends on the size
of the index fields. The following table defines the size of a hash column for
various data types:

Field Type Hash Column Size


char 1
char(n) n
short 3
date 4
long 5
float (digv + diga + 2) / 2
double (digv + diga + 2) / 2

If an index consists of more than one field, the size of the hash column equals the
total of the sizes required for each field. For example, if the index consists of a
long field (size of 5) and a char field (size of 1), the column size is 6.

Index Ordering

In Informix, the default order when creating an index is ascending. There is no


provision for a descending index. The descending hash column is a 1’s
complement of the ascending column with an ascending index, thereby
simulating a descending index.

Mapping MK to Informix 5–5


Data Types

Data Types
The following table shows the mapping between MK and Informix data types:

MK Informix
BDB_CHAR Short
BDB_ENUM
BDB_SHORT
BDB_LONG Long
BDB_MAIL
BDB_TIME
BDB_TEXT
BDB_BITSET
BDB_DATE Date
BDB_FLOAT Float4
BDB_DOUBLE Double
BDB_STRING CstringType

Dates

In MK, a date is stored as the number of days from the year 0001. Informix stores
dates as the number of days since December 31, 1899.

Converting from the MK date to the Informix date involves copying the day of
month, month, and year from MK (using the MK function) and passing these to
an Informix function that returns a corresponding Informix date. Converting
from Informix to MK follows the reverse path.

In MK, date 0 means that the date is not specified. In this case, minimum values
are used to create the Informix date:
day of month = month = year = 1

Similarly, when day of month = month = year = 1 is retrieved from Informix,


the MK date is set to zero.
day of month = 1,month = 1,year = 1753

5–6 MK in the Informix Environment


Data Types

Strings

The MK BDB_STRING data type is mapped to the Informix CSTRINGTYPE


data type. When storing data for the CSTRINGTYPE type, Informix strips
trailing blanks to save disk space. When retrieving the data, however, the
Informix driver replaces the appropriate number of blanks before passing the
data back to the user. The user never sees this truncation.

Mapping MK to Informix 5–7


Chapter

Tuning
6

Overview ................................................................................... 6–1


Testing Performance ......................................................................... 6–2
Adjusting Parameters ........................................................................ 6–3
Index Optimization ................................................................... 6–3
Refresh Time ........................................................................ 6–3

Tuning 6–i
Chapter

Tuning
6

Overview
Tuning the database typically involves determining the requirements of your
environment and how data is being accessed, and then modifying data structures
as necessary. This chapter provides information to help you identify
performance bottlenecks, adjust initialization parameters, and manage the
database.

Tuning 6–1
Testing Performance

Testing Performance
To determine which table actions are time-consuming, you can set the INFPROF
environment variable to a number of seconds. All SELECT actions that take
longer than that are written to a file called infprof. This file lists information
such as the time for executing the cursor and retrieval of the result. The infprof
file is stored in the directory where the Informix driver was started.

You can specify the INFPROF variable in the tabledef6.0 file for a particular
table, as follows:
c
tiitm:*:informix(INFORMIXDIR=/darktools,INFPROF=0.0):N

In this example, the INFPROF variable is set to 0.4 seconds for the tables tdsls001
and zero seconds for all itm tables. If a SELECT takes more than 0.4 seconds for
table tdsls001, an entry is generated for the infprof file. For itm tables, all
SELECTS generate entries.

Note: If two tables have different INFPROF values, a separate driver is started
when the second table is accessed.

In the following from an INFPROF file, the number of seconds (profiling value)
is 0.00, indicated in the first row of the file.
98-4-01 [16:43:43]: Profiling value = 0.00 sec
Pid Table Owner I Mode Cache Exe Fetch Exe Fetch Tot
<12538> tiitm055000 bob 1 FIRST : - 0.02 0.09 - - 0.20
<12538> tiitm055000 bob 1 EQUAL : - 0.00 0.00 - - 0.08
<12538> tiitm055000 bob 1 EQUAL : 0.00 0.00
<12538> tiitm055000 bob 1 EQUAL : 0.00 0.00
<12538> tiitm055000 bob 1 NEXT : - 0.00 0.02 - - 0.10
<12538> tiitm055000 bob 1 NEXT : - - 0.00 - - 0.00
<12538> tiitm055000 bob 1 PREV : - 0.00 0.01 - - 0.09
<12538> tiitm055000 bob 1 PREV : - - 0.00 - - 0.00
<12538> tiitm055000 bob 6 FIRST : - 0.05 0.09 - - 0.15

Using the information in this file, you can determine when results are retrieved
from cache memory and how long it takes to fetch and execute various actions.

6–2 MK in the Informix Environment


Adjusting Parameters

Adjusting Parameters
The most common way to tune the driver is by changing the values for the
following parameters:
■ Index optimization
■ Refresh time

Index Optimization

Index optimization involves managing the effects of the hash column, which has
a value obtained by combining all key field values using an algorithm. The
index is created on this column, instead of the conventional key fields. This
reduces search time since the index consists of a single column that maintains the
sort order of the components. You can indicate single level index optimization in
the storage file inf_storage to improve performance.

Refresh Time

Refresh time can be changed to control fetch optimization and caching. You can
set the refresh time in the storage file inf_storage.

Refer to Chapter 4, “Maintaining Driver Files,” for more information on editing


the inf_storage file.

Tuning 6–3
Chapter

Troubleshooting
7

Overview ................................................................................... 7–1


Error Mapping and Reporting ................................................................ 7–2
Database Errors ............................................................................. 7–3
Tracing ..................................................................................... 7–6
Database Limitations ......................................................................... 7–7
Informix Locking ........................................................................ 7–7
Read Isolation ........................................................................... 7–8
Repeatable Reads ........................................................................ 7–9
Update Statistics ......................................................................... 7–9
Maximum Number of Locks .............................................................. 7–9
Tasks the Informix Driver Handles ....................................................... 7–10

Troubleshooting 7–i
Chapter

Troubleshooting
7

Overview
This chapter provides tips for troubleshooting in the MK Informix environment.
It includes information about database errors, tracing, and some of the
limitations of the Informix database.

Troubleshooting 7–1
Error Mapping and Reporting

Error Mapping and Reporting


There are four categories of errors for MK:

Code Type of Error


Codes 1-99 UNIX errors
Codes 100-899 Informix database errors
Codes 900-999 Network errors
Codes > 1000 Informix driver errors

If an SQL statement generates an error, an error code is returned. With Informix,


this error code is a negative number. The Informix driver maps this to a
corresponding MK database error code and that error code is sent back to MK.

However, some Informix errors have no corresponding MK error code. These


codes are passed back to MK after adding 1000 to the absolute value of the error
code. For example, if Informix error -399 cannot be mapped, it is passed back as
1399 (1000 + abs(-399)). You can get the actual error code by subtracting 1000
and then making the result negative.

You can also display the error message associated with any Informix error code
using the option Show Error Message for Informix SQL or ISAM Code or the
Show Error Message option in inf7_admin6.0.

The Informix driver also logs each error it encounters into a log file names
$BSE/log/log.informix. Use this file along with other log files to analyze any
errors encountered.

7–2 MK in the Informix Environment


Database Errors

Database Errors
Refer to the following table for a description of database errors.

Code Error Name Description


100 EDUPL Duplicate value
101 ENOTOPEN Table is not open
102 EBADARG Bad argument
103 EBADKEY Bad key
104 ETOOMANY Too many files open
105 EBADFILE Bad ISAM file format
106 ENOTEXCL Table is not exclusively locked
107 ELOCKED Record is locked
108 EKEXISTS Key already exists
109 EPRIMKEY Is primary key
110 EENDFILE End of file reached
111 ENOREC No record found
112 ENOCURR No current record
113 EFLOCKED Table is locked
114 EFNAME File name too long
116 EBADMEM Cannot allocate memory
117 EBADCOLL Bad custom collating
123 ENOSHMEM No shared memory initialized
125 ENONFS Cannot use nfs
127 ENOPRIM No primary key
129 EUSER Too many users
131 ENOFREE No free disk space
132 EROWSIZE Row size too big
133 EAUDIT Audit trail exists
134 ENOLOCKS No more locks
135 ENOTBL No more tables for commit
136 ENOSPACE No space in shared memory

Troubleshooting 7–3
Database Errors

Code Error Name Description


137 ENOADDR No space in before/after image table
138 ENOFTBL No space for table entry
139 ENOCOMMIT No free commits available
140 ETRANSON Invalid operation when transaction is on
141 ETRANSOFF Invalid operation when transaction is off
142 EADMON Some administration process is running
143 ENOFLUSH No flusher entry available
201 EROWCHANGED Record changed after delayed lock
202 EDBLOCKED Database is locked
203 ETRANSACTIONON Action not allowed within transaction
204 EISREADONLY Transaction is read only
205 ENOTINRANGE Out of range
206 ENOTLOCKED Record is not locked
207 EAUDIT Error of audit trailer
208 EPERMISSION Permission denied
209 EMIRROR Error on mirroring of database
501 EMEMORY Internal memory error
502 EON Already logged on
503 EBADADRS Illegal address
504 EBADFLD Undefined column
505 ENOSERVER No server specified
506 ENOTABLE Table does not exist
507 ETABLEEXIST Table already exists
508 ENOTON Not logged on to a database
509 EBADCURSOR Bad memory cursor
510 EDBNOTON Database server not on
511 EWRONGVERSION Version of client versus server not correct
512 EDDCORRUPT Corrupted data dictionary
513 ENODD Data dictionary not found
514 ESECURITY Security error

7–4 MK in the Informix Environment


Code Error Name Description
515 Object not licensed
600 EREFERENCE General reference error
601 EREFLOCKED Reference table is locked
602 EUNDERREF Reference is not defined
604 EREFUPDATE Cannot update reference
605 EREFEXISTS Reference exists, cannot delete
606 EREFNOTEXISTS Reference does not exist
607 ENOREFTBL Reference table not found
608 ENOREFCNT No reference counter
609 EUPDREFCNT Error at update of reference counter
850 EFATALSTART Driver failed to start

Troubleshooting 7–5
Tracing

Tracing
The MK Informix driver lets you trace various commands as they are executed
by the driver. You can control the information tracked through an environment
variable called SQLLOG. The information is stored in a trace file in your
working directory and is named sql.log. This file is useful for debugging and
monitoring low-level performance.

The following table lists the attributes that you can trace, and their SQLLOG
required value (numeric values are octal values).

Value Description
0001 Puts the user information into the trace file, including the database
user name, the user group, and other users in that group.
0002 Puts MK data dictionary information in the trace file for each table
accessed by the driver. This includes table column and index
information, number of hash columns, and refresh time.
0004 Each SQL statement that generates an error is logged in the trace file.
0010 All field values for the current record are put in the trace file.
0020 Each table action, such as create table (TCRTBL), is logged.
0040 Each database action, such as commit work (DCOM), is logged.
0100 Miscellaneous debug information is put in the trace file.

To trace a combination of attributes, set SQLLOG to the sum of individual


numbers. For example, to trace table data dictionary (DD) information, SQL
statements, and table actions, set SQLLOG to 0026 (0002+0004+0020). The
variable SQLLOG can also be put in the file tabledef6.0 (with Maintain Database
Definitions).

7–6 MK in the Informix Environment


Database Limitations

Database Limitations
There are some special characteristics of the Informix database that affect the
behavior of the MK Informix driver. In general, these characteristics involve
how Informix handles locking and updating tables.

Informix Locking

When a row is updated or deleted, it is locked until the end of the transaction.
Informix also locks the next and previous key value in the index. This can result
in some expected behavior. For example, consider a table with five rows, a
unique index, and a duplicate index (ascending).

Table

row1

row2 Process 1
index1

index2

row3
Process 2
row4

row5

Unique Index Example

If Process 1 reads row2 for an update using a unique index, row2 is locked. The
previous key value (row1) and the next key value (row3) are also locked. When
Process 2 attempts to read row1 for update using a unique index, Informix
allows the row to be read in spite of the lock; however, if Process 2 tries to delete
row1, the delete fails with "key locked" error. Although the read for update was
successful, the delete fails because the key was already locked by Process 1.

Duplicate Index Example

Consider the same table as describe above with a DUPLICATE index (index2)
and all rows with the same key values with respect to index2.

If Process 1 reads row4 for update using the duplicate index and deletes row4,
row4 is locked. But since all rows have the same key values, effectively, all rows
are now locked with respect to this key. If Process 2 attempts to read row1 for
update using the duplicate index, all rows for this index are locked; therefore, the
process fails with a "record locked" error.

Troubleshooting 7–7
Database Limitations

However, if Process 2 changes to the unique index and reads row1 for update,
the read will be successful. This is because all records have different key values
with respect to this index (since it is a unique index).

The above example assumes that there was no hash optimization. If the index
has hash optimization, the hash column has unique values even if the index is a
duplicate. So in this case, only the previous record is affected. Other records
having same key value have unique hash values and are not affected.

Read Isolation

By default, the MK Informix driver uses committed read isolation. You cannot
read a locked row using this isolation, so when MK issues a "read (without lock)"
request, the Informix driver changes the isolation to dirty read.

A dirty read can return a row that is being updated or inserted and not yet
committed. If the row is being updated, the dirty read returns the updated values
and not the original values. If a row is deleted, a dirty read will skip that row
even if the delete is not committed. This can lead to problems. For example:
■ If Process 1 deletes row2 and Process 2 reads first (row1) then read next, the
driver tries to read the next row using the default isolation, which is
committed read, and gets "locked" error.
■ The driver then changes the isolation to dirty read and tries to read again.
■ The dirty read skips the deleted row (row2) and returns row3.

Similarly, consider the case when Process 1 reads a row without locking; Process
2 updates the same row but does not do a commit, and then Process 1 issues a
ROW_CHANGED. The driver tries to read the same row using the default
committed read isolation and gets a locked error so it changes the isolation to
dirty read. In this case, dirty read returns updated values even though Process 2
has not done a commit yet.

Note: Some databases support read consistent transactions so that all queries on
the same object see the same data (taken at the start of the transaction. However,
Informix does not support read consistent transactions, so the command SET
TRANSACTION READONLY has no effect on the subsequent query.

7–8 MK in the Informix Environment


Database Limitations

Repeatable Reads

After reading a row for update, if the cursor is closed without doing the update,
the lock is released. This results in inconsistent behavior as another process can
now lock the row even though the first process has successfully read the row for
update. To prevent this, the Informix driver changes isolation level to repeatable
read before closing a cursor, if it was used to read a row for update. Now the
row remains locked even when cursor is closed.

Update Statistics

The Informix query optimizer uses the data generated by the SQL command
Update Statistics to determine query execution plan. However, table statistics
are only updated when you execute the Update Statistics statement using ISQL.
The Informix driver does not execute the Update Statistics statement at any time.

After a table is modified extensively, you should remember to platform the


update statistics activity to improve the performance of your system. In
addition, the DBA should keep track of tables that undergo heavy modification
and do the update statistics periodically for the installation.

Note: For large tables, this process may take some time, so it should be done
when the load on the system is light.

If only a few tables in the database undergo modifications, update statistics can
be done for individual tables. If a large number of tables in a database are
modified, update statistics for database will be faster and will update all tables in
the database.

Maximum Number of Locks

When a row is read for update, two locks are used. When the row is actually
deleted, Informix requires additional locks for key values in the index. If almost
all locks in an Informix system are already in use, it is possible that the delete
cannot get the required number of locks and will fail, giving the error "no more
locks." This situation may arise if heavy delete/insert/update activity is going
on concurrently.

In general, this is a rare condition, but if an installation frequently gets this error,
the DBA should increase the maximum number of locks in the Informix system
using the onmonitor utility.

Troubleshooting 7–9
Database Limitations

Tasks the Informix Driver Handles

Unlike other databases, data definition statements like create table/index or drop
table/index are not single transactions in Informix. Thus, they need to be
explicitly committed. To present consistent interface to applications, the MK
Informix driver does a commit internally after executing such statements.

In Informix, there is no concept of a primary key. Thus, any index on table can
be dropped. However, the MK Informix driver prevents the dropping of the
primary (index1) index.

In Informix, temporary tables cannot be granted table privileges. Therefore,


temporary tables cannot be group tables (which require table privileges be
granted for all users).

7–10 MK in the Informix Environment


Appendix

Files and Executables


A

Executables ................................................................................ A–1


Driver Files ................................................................................ A–2
Table Definition (tabledef6.0) ............................................................ A–3
IPC File (ipc_info) ....................................................................... A–4

Files and Executables A–i


Appendix

Files and Executables


A
This appendix lists various executables and files required by the Informix driver
and the directories where they are located.

Executables
MK uses the following Informix executable files:

File Description
inf7_srv6.0 The Informix driver. Resides in $BSE/bin.
inf7_exec6.0 Auxiliary file used by the driver. Resides in $BSE/bin.
This executable should be owned by root and should have
the setuid bit on (permission 4750).
inf7_inst6.0 The script for installing the Informix driver, setting up the
initial database group, required users, and default table
specifications. Resides in $BSE/bin.
inf7_admin6.0 The shell script for administration. This script calls
inf7_maint6.0. Resides in $BSE/bin.
inf7_maint6.0 The program internally called by inf7_admin6.0 and
inf7_inst6.0 for doing various driver administration
functions, such as add user to group. Resides in $BSE/bin.

Files and Executables A–1


Driver Files

Driver Files
The following table lists the MK Informix driver files.

Driver File Description


inf_users Contains information about all MK users who are going to
access the Informix driver. It maps MK users to an
Informix database. It is created by inf7_inst6.0 during
installation. It is located in $BSE/lib/informix.
inf_groups Contains all Informix database (group) names accessible
by MK users. It is created by inf7_inst6.0 during
installation. It is located in $BSE/lib/informix.
inf_storage Contains database storage specifications for MK tables and
indexes. It is created during installation by inf7_inst6.0. It
is located in $BSE/lib/informix.
inf_instmsg6.0 Contains the installation message. It is created by the
installation scrip and is located in $BSE/lib/informix.
tabledef6.0 Identifies the type of the driver to use for accessing a table,
plus other driver parameters. It is maintained through
thee Assign Tables to Databases (ttaad4111m000) session.
It is located in $BSE/lib.
ipc_info Defines the UNIX path name for the driver executables
and the protocols used for communication between the
MK shell and driver process. It is located in $BSE/lib.
For information about this file, refer to the MK System
Administrator's Guide.

A–2 MK in the Informix Environment


Driver Files

Table Definition (tabledef6.0)

Each line in this file consists of four fields separated by a colon


( : ). The format of the line is as follows:
[{<user>}]<table_name>:<company number>:<driver specification>:<audit trail>

In this file, you identify the database used for the table, a host name for a remote
table, or a list of drivers and remote sites, separated by an ampersand ( & ). In
addition to specifying the database driver as Informix, you can use this file to
assign values for the following parameters:

Parameter Description
INFORMIXDIR Contains the full path name of the directory where the
Informix database is installed. If there are multiple
versions of Informix on your system, enter the name of the
directory containing the version you want to access.
When starting the Informix driver, the MK shell reads and
sets this environment variable so that the Informix driver
uses the corresponding database installation.
INFPROF Time for profiling SELECT statement execution time.
SQLLOG File for tracing various database actions.

Sample Entries
tiitm990:*:informix(INFORMIXDIR=/storm/informix,INFPROF=1):N
tiitm999:*:darkman:N
tiitm055:*:informix(INFORMIXDIR=/storm/informix)&ingres
(II_SYSTEM=/darktools)&viper:N
*:*:informix(INFORMIXDIR=/darktools/informix):N

In this example, table tiitm990 for all companies (*) is in the Informix database;
all tiitm999xxx tables are on the system darkman; and tiitm055xxx tables are
created in informix, ingres, and on the remote machine viper.

Files and Executables A–3


Driver Files

IPC File (ipc_info)

Information about the database communication method is stored in the ipc_info


file. Each entry in this file consists of the following fields:
<driver_type><mode><semaphore_key><message_key><protocol> <path_name>

where:
■ driver_type — name of the driver recorded in tabledef6.0.
■ mode — drivers can operate in single(s) or multiple(m) client mode.
■ semaphore_key — key to be used for creating a semaphore.
■ message_key — key to be used for creating a message queue
■ protocol — type of the protocol used: socket (s), pipe (p), or message queue
(m).
■ path_name — full pathname of the driver executable file.

For example, a typical ipc_info file might look like this:

driver
operation mode
semaphore key
message key

protocol (s/m/p)
path of executable

ba6.0 s 601 610 p ${BSE}/bin/ba6.0


audit s 501 510 p ${BSE}/bin/audit_srv6.0
bx6.0 s 302 320 p ${BSE}/bin/bx6.0
informix s 305 350 p ${BSE}/bin/inf_srv.exe

For more information about defining databases and the ipc_info file, refer to the
MK System Administrator's Guide.

A–4 MK in the Informix Environment


Appendix

Determining Table Space


B

Introduction ................................................................................. B–1


Changing Extent Size ........................................................................ B–2
Implications of Extent Size ................................................................ B–2
How to Change Extent Size ............................................................... B–2
Estimating Table Space ....................................................................... B–3
General Overhead........................................................................ B–3
Row Requirements ....................................................................... B–3
Effect of Hash Optimization............................................................... B–4

Determining Table Space B–i


Appendix

Determining Table Space


B

Introduction
When you create a table using Informix, you can indicate how much space you
want to reserve for that table. The create table statement allows you to specify
two parameters:
■ Ei — size of initial extent
■ En — size of each additional extent

Informix manages the disk space in a dbspace by initially reserving an extent of


size Ei. When the first extent becomes full, Informix reserves a new extent of size
En. When that extent gets full, it adds another extent of size En, and so on.

Determining Table Space B–1


Changing Extent Size

Changing Extent Size


When a table occupies 64 extents, Informix doubles the size of the next extent to
be allocated. This doubling repeats every 64 extents. Therefore, if initially En is
8 pages and the table stretches to 64 extents, then from the 65th extent onwards,
Informix will use a size of 16 pages for the extent. If the table grows to 128
extents, Informix will increase the page extent size to 32 pages for extent 129
onwards.

Implications of Extent Size

Specifying extent sizes is optional. Default for both is 8 pages. However, if you
use the default extent size for a large table, you may exceed the maximum
number of extents allowed per tblspace, which causes an out-of-space error.

If performance is the main criterion, you must create extents large enough to
handle any contingency. But this may result in inefficient utilization of disk
space. If disk space is critical, estimate the exact storage.

How to Change Extent Size

Informix provides the facility of changing the size of any additional extent (En),
by using the alter table statement. The alter table statement does not, however,
affect existing extents (including the one currently being written on). It only
affects extents created after issuing the statement.

The MK Informix driver also provides the facility of specifying the initial and
next extent sizes for a table. You can use the maintenance utility inf7_admin6.0
or the MK Informix utilities sessions to alter the next extent size of an existing
table.

B–2 MK in the Informix Environment


Estimating Table Space

Estimating Table Space


To determine table extent sizes, you need to know how much space a table
requires. For a table, there is some overhead, in addition to the space required to
store the data.

General Overhead

The exact amount of space lost to overhead is subject to several factors, making it
difficult to derive a precise formula for general overhead. Use these guidelines
to make an initial estimate:
■ Determine total row length, page space to be used, and how many rows can
fit on a page
■ Determine the total index length
■ Add 25% to cover the overhead for index tree structure

Index overhead can vary substantially (either higher or lower) from the 25%
guideline, depending on how packed the b-trees are from deletion and insertion.

Row Requirements

Rows require space for both columns and indexes. The row length is the sum of
the lengths of the individual columns for that row. The index length is the sum
of index entries of all indexes for that table. The length of a single index entry is
the length of the key plus eight bytes to store a pointer to the corresponding row.

After determining the size of each row, you should estimate how many rows are
going to be present in the table:
■ Estimate the number of rows you want to store initially.
■ Use this estimate to determine the size of initial extent (Ei).
■ Estimate the table growth for a reasonable period of time and divide the
space needed for additional rows by seven (the number of additional extents
that Informix can directly access without using additional overhead).
■ Use this estimate to set the size of next extent (En).

Determining Table Space B–3


Estimating Table Space

Effect of Hash Optimization

When a table has hash optimization, additional hash columns are created
internally. Their size should be taken into account for calculating the row size.
Also, indexes are actually created on hash columns instead of original table
column s; therefore, the index space requirement also changes.

Note: You can use the MK maintenance tools to obtain the row size and index
sizes for existing tables. This information can be used to alter the next extent size
of a table.

⇒ To estimate table space:


1. Determine each index length. Add 8 bytes to length of the key.
2. Sum up all index entries from step 1. This will be the total index length.
3. Add 25% to the sum from step 2.
4. Estimate the initial number of rows.
5. Determine index space needed. This is obtained by multiplying the result of
step 3 by the number of rows in step 4.
6. Convert index space to kilobytes. Divide index space by 1024.
7. Determine page length to be used. Get your systems page length (ask your
DBA for this). Subtract 32 to get usable page length.
8. Determine row length by summing up all column lengths in the row.
9. Determine how many rows can fit on a page. To do this, divide the page size
in step 7 by the row length in step 8 and round down to the greatest whole
number.
10. Determine the number of data pages for initial table by dividing the number
of rows from step 4 by the number of rows per page in step 9 and round up.
11. Determine the space needed for data pages in the initial extent, by
multiplying the number of pages determined in step 10 by the size of a full
page.
12. Convert data size to kilobytes by dividing the result of step 11 by 1024.
13. Determine the size of the initial extent (Ei) in kilobytes. Add the results of
step 12 and step 6.
14. Estimate table growth. Guess the number of subsequent rows.
15. Size subsequent extents:
■ Repeat steps 5 and 6 for index space and steps 10-13 for data space.
■ Use the estimate in step 14 as the number of rows in step 5 and 10.
■ Divide the final result by 7.
This gives you the next extent size (En).

B–4 MK in the Informix Environment


Estimating Table Space

Sample

The following example illustrates how to estimate extent sizes.

Column Type Length


item_num smallint 2
order_num integer 4
stock_num smallint 2
manu_code char(3) 3
quantity smallint 2
total_price money(8) 5

Basic Requirements:
■ Index 1: order_num
■ Index 2: stock_num, manu_code
■ Initial rows: 20,000
■ Additional rows: 35,000
■ Assume page length: 2048

Steps:
1. Determine each index length and add 8 bytes:
index 1 = 4 + 8 = 12
index 2 = 2 + 3 + 8 = 13

2. Determine total index length:


total index = 12 + 13 = 25

3. Increase by 25%:
Index + overhead = 25 * 1.25 = 31.3

4. Estimate initial number of rows:


Initial number of rows = 20,000

5. Multiply index space per row by the number of rows:


rows * space per row = 20,000 * 31.3 = 626,000 bytes

6. Convert index space to kilobytes:


Index space in kilobytes = 626,000 / 1024 = 612 kbytes

7. Determine system page length and subtract 32 to get usable page length:
Corrected page length = 2048 -32 = 2016 bytes

Determining Table Space B–5


Estimating Table Space

8. Determine row length by summing up all column lengths in the row:


Row length = 2 + 4 + 2 + 3 + 2 + 5 = 18 bytes

9. Divide the page size by the row length and round down:
Number of rows per page = 2016 / 18 = 112

10. Divide the number of rows by the number of rows per page:
Number of data pages = 20,0000 / 112 = 178.6 = 179

11. Multiply the number of pages by the size of a full page:


Space for data pages = 179 * 2048 = 366,592 bytes

12. Convert data size to kilobytes:


Data space in kilobytes = 366,952 / 1024 = 358 kbytes

13. Determine the size of the initial extent (Ei) in kilobytes:


(Ei) = 358 + 612 = 970 kbytes

14. Estimate the number of subsequent rows:


Subsequent rows = 35,000

15. Size subsequent extents (En):


Index space = 35,000 * 31.3 = 1,095,500 bytes
In kilobytes = 1095500 / 1024 kbytes = 1070 kbytes
Number of additional data pages = 35000/112 = 313
Additional data space = 313 * 2048 = 641,024 bytes
Data space in kilobytes = 641024/1024 = 626 kbytes
Data space + index space = 626 + 1070 = 1696 kbytes
Data space per extent (7) = 1696/7 = 243 kbytes

16. Set En = 243 kbytes.

B–6 MK in the Informix Environment

You might also like